@vuepress/theme-default 2.0.0-beta.8 → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/lib/client/components/AutoLink.vue +119 -0
  2. package/lib/client/components/DropdownTransition.vue +15 -24
  3. package/lib/client/components/Home.vue +12 -130
  4. package/lib/client/components/HomeContent.vue +5 -0
  5. package/lib/client/components/HomeFeatures.vue +23 -0
  6. package/lib/client/components/HomeFooter.vue +17 -0
  7. package/lib/client/components/HomeHero.vue +98 -0
  8. package/lib/client/components/Navbar.vue +60 -95
  9. package/lib/client/components/NavbarBrand.vue +55 -0
  10. package/lib/client/components/NavbarDropdown.vue +126 -0
  11. package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +73 -58
  12. package/lib/client/components/Page.vue +16 -15
  13. package/lib/client/components/PageMeta.vue +51 -66
  14. package/lib/client/components/PageNav.vue +47 -60
  15. package/lib/client/components/Sidebar.vue +12 -32
  16. package/lib/client/components/SidebarItem.vue +87 -0
  17. package/lib/client/components/SidebarItems.vue +57 -0
  18. package/lib/client/components/ToggleColorModeButton.vue +57 -0
  19. package/lib/client/components/ToggleSidebarButton.vue +21 -24
  20. package/lib/client/components/global/Badge.vue +24 -26
  21. package/lib/client/components/global/CodeGroup.d.ts +5 -4
  22. package/lib/client/components/global/CodeGroup.js +85 -17
  23. package/lib/client/components/global/CodeGroupItem.vue +23 -17
  24. package/lib/client/components/global/index.d.ts +4 -0
  25. package/lib/client/components/global/index.js +4 -0
  26. package/lib/client/composables/index.d.ts +7 -5
  27. package/lib/client/composables/index.js +7 -5
  28. package/lib/client/composables/useDarkMode.d.ts +12 -0
  29. package/lib/client/composables/useDarkMode.js +57 -0
  30. package/lib/client/composables/useNavLink.d.ts +6 -1
  31. package/lib/client/composables/useNavLink.js +5 -2
  32. package/lib/client/composables/useResolveRouteWithRedirect.js +2 -2
  33. package/lib/client/composables/useScrollPromise.js +1 -1
  34. package/lib/client/composables/useSidebarItems.d.ts +13 -8
  35. package/lib/client/composables/useSidebarItems.js +42 -38
  36. package/lib/client/composables/useThemeData.d.ts +2 -2
  37. package/lib/client/composables/useThemeData.js +1 -1
  38. package/lib/client/composables/useUpdateDeviceStatus.d.ts +7 -0
  39. package/lib/client/composables/useUpdateDeviceStatus.js +25 -0
  40. package/lib/client/config.d.ts +3 -0
  41. package/lib/client/config.js +44 -0
  42. package/lib/client/index.d.ts +3 -4
  43. package/lib/client/index.js +3 -2
  44. package/lib/client/layouts/Layout.vue +133 -136
  45. package/lib/client/layouts/NotFound.vue +27 -0
  46. package/lib/client/shim.d.ts +5 -0
  47. package/lib/client/styles/{_wrapper.scss → _mixins.scss} +7 -2
  48. package/lib/client/styles/_variables.module.scss +5 -0
  49. package/lib/client/styles/_variables.scss +0 -28
  50. package/lib/client/styles/arrow.scss +4 -6
  51. package/lib/client/styles/badge.scss +14 -11
  52. package/lib/client/styles/code-group.scss +9 -2
  53. package/lib/client/styles/code.scss +35 -49
  54. package/lib/client/styles/custom-container.scss +82 -18
  55. package/lib/client/styles/home.scss +32 -24
  56. package/lib/client/styles/index.scss +4 -4
  57. package/lib/client/styles/layout.scss +82 -73
  58. package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +36 -50
  59. package/lib/client/styles/navbar.scss +106 -50
  60. package/lib/client/styles/normalize.scss +200 -0
  61. package/lib/client/styles/page.scss +24 -8
  62. package/lib/client/styles/sidebar.scss +69 -87
  63. package/lib/client/styles/transitions.scss +13 -4
  64. package/lib/client/styles/vars-dark.scss +68 -0
  65. package/lib/client/styles/vars.scss +149 -0
  66. package/lib/client/utils/index.d.ts +3 -2
  67. package/lib/client/utils/index.js +3 -2
  68. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  69. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  70. package/lib/client/utils/resolveEditLink.d.ts +2 -2
  71. package/lib/client/utils/resolveEditLink.js +15 -9
  72. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  73. package/lib/client/utils/resolveRepoType.js +3 -1
  74. package/lib/node/defaultTheme.d.ts +4 -4
  75. package/lib/node/defaultTheme.js +111 -48
  76. package/lib/node/index.d.ts +4 -4
  77. package/lib/node/index.js +5 -17
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +4 -2
  79. package/lib/node/utils/assignDefaultLocaleOptions.js +13 -13
  80. package/lib/node/utils/index.d.ts +2 -5
  81. package/lib/node/utils/index.js +2 -17
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +2 -20
  83. package/lib/node/utils/resolveContainerPluginOptions.js +4 -66
  84. package/lib/shared/index.d.ts +3 -3
  85. package/lib/shared/index.js +3 -15
  86. package/lib/shared/nav.d.ts +16 -18
  87. package/lib/shared/nav.js +1 -2
  88. package/lib/shared/options.d.ts +51 -6
  89. package/lib/shared/options.js +1 -2
  90. package/lib/shared/page.d.ts +15 -6
  91. package/lib/shared/page.js +1 -2
  92. package/package.json +49 -29
  93. package/templates/build.html +34 -0
  94. package/CHANGELOG.md +0 -403
  95. package/lib/client/clientAppEnhance.d.ts +0 -3
  96. package/lib/client/clientAppEnhance.js +0 -30
  97. package/lib/client/clientAppSetup.d.ts +0 -2
  98. package/lib/client/clientAppSetup.js +0 -11
  99. package/lib/client/components/DropdownLink.vue +0 -141
  100. package/lib/client/components/NavLink.vue +0 -115
  101. package/lib/client/components/SidebarChild.d.ts +0 -6
  102. package/lib/client/components/SidebarChild.js +0 -91
  103. package/lib/client/components/global/OutboundLink.vue +0 -30
  104. package/lib/client/layouts/404.vue +0 -38
  105. package/lib/client/styles/_normalize.scss +0 -148
  106. package/lib/client/styles/plugins.scss +0 -18
  107. package/lib/client/styles/sr-only.scss +0 -12
  108. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  109. package/lib/node/utils/resolveActiveHeaderLinksPluginOptions.js +0 -16
  110. package/lib/node/utils/resolveGitPluginOptions.d.ts +0 -6
  111. package/lib/node/utils/resolveGitPluginOptions.js +0 -22
  112. package/lib/node/utils/resolveMediumZoomPluginOptions.d.ts +0 -6
  113. package/lib/node/utils/resolveMediumZoomPluginOptions.js +0 -17
@@ -0,0 +1,149 @@
1
+ :root {
2
+ // brand colors
3
+ --c-brand: #3eaf7c;
4
+ --c-brand-light: #4abf8a;
5
+
6
+ // background colors
7
+ --c-bg: #ffffff;
8
+ --c-bg-light: #f3f4f5;
9
+ --c-bg-lighter: #eeeeee;
10
+ --c-bg-dark: #ebebec;
11
+ --c-bg-darker: #e6e6e6;
12
+ --c-bg-navbar: var(--c-bg);
13
+ --c-bg-sidebar: var(--c-bg);
14
+ --c-bg-arrow: #cccccc;
15
+
16
+ // text colors
17
+ --c-text: #2c3e50;
18
+ --c-text-accent: var(--c-brand);
19
+ --c-text-light: #3a5169;
20
+ --c-text-lighter: #4e6e8e;
21
+ --c-text-lightest: #6a8bad;
22
+ --c-text-quote: #999999;
23
+
24
+ // border colors
25
+ --c-border: #eaecef;
26
+ --c-border-dark: #dfe2e5;
27
+
28
+ // custom container colors
29
+ --c-tip: #42b983;
30
+ --c-tip-bg: var(--c-bg-light);
31
+ --c-tip-title: var(--c-text);
32
+ --c-tip-text: var(--c-text);
33
+ --c-tip-text-accent: var(--c-text-accent);
34
+ --c-warning: #ffc310;
35
+ --c-warning-bg: #fffae3;
36
+ --c-warning-bg-light: #fff3ba;
37
+ --c-warning-bg-lighter: #fff0b0;
38
+ --c-warning-border-dark: #f7dc91;
39
+ --c-warning-details-bg: #fff5ca;
40
+ --c-warning-title: #f1b300;
41
+ --c-warning-text: #746000;
42
+ --c-warning-text-accent: #edb100;
43
+ --c-warning-text-light: #c1971c;
44
+ --c-warning-text-quote: #ccab49;
45
+ --c-danger: #f11e37;
46
+ --c-danger-bg: #ffe0e0;
47
+ --c-danger-bg-light: #ffcfde;
48
+ --c-danger-bg-lighter: #ffc9c9;
49
+ --c-danger-border-dark: #f1abab;
50
+ --c-danger-details-bg: #ffd4d4;
51
+ --c-danger-title: #ed1e2c;
52
+ --c-danger-text: #660000;
53
+ --c-danger-text-accent: #bd1a1a;
54
+ --c-danger-text-light: #b5474d;
55
+ --c-danger-text-quote: #c15b5b;
56
+ --c-details-bg: #eeeeee;
57
+
58
+ // badge component colors
59
+ --c-badge-tip: var(--c-tip);
60
+ --c-badge-warning: #ecc808;
61
+ --c-badge-warning-text: var(--c-bg);
62
+ --c-badge-danger: #dc2626;
63
+ --c-badge-danger-text: var(--c-bg);
64
+
65
+ // transition vars
66
+ --t-color: 0.3s ease;
67
+ --t-transform: 0.3s ease;
68
+
69
+ // code blocks vars
70
+ --code-bg-color: #282c34;
71
+ --code-hl-bg-color: rgba(0, 0, 0, 0.66);
72
+ --code-ln-color: #9e9e9e;
73
+ --code-ln-wrapper-width: 3.5rem;
74
+
75
+ // font vars
76
+ --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
77
+ Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
78
+ --font-family-code: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
79
+
80
+ // layout vars
81
+ --navbar-height: 3.6rem;
82
+ --navbar-padding-v: 0.7rem;
83
+ --navbar-padding-h: 1.5rem;
84
+ --sidebar-width: 20rem;
85
+ --sidebar-width-mobile: calc(var(--sidebar-width) * 0.82);
86
+ --content-width: 740px;
87
+ --homepage-width: 960px;
88
+ }
89
+
90
+ // plugin-back-to-top
91
+ .back-to-top {
92
+ --back-to-top-color: var(--c-brand);
93
+ --back-to-top-color-hover: var(--c-brand-light);
94
+ }
95
+
96
+ // plugin-docsearch
97
+ .DocSearch {
98
+ --docsearch-primary-color: var(--c-brand);
99
+ --docsearch-text-color: var(--c-text);
100
+ --docsearch-highlight-color: var(--c-brand);
101
+ --docsearch-muted-color: var(--c-text-quote);
102
+ --docsearch-container-background: rgba(9, 10, 17, 0.8);
103
+ --docsearch-modal-background: var(--c-bg-light);
104
+ --docsearch-searchbox-background: var(--c-bg-lighter);
105
+ --docsearch-searchbox-focus-background: var(--c-bg);
106
+ --docsearch-searchbox-shadow: inset 0 0 0 2px var(--c-brand);
107
+ --docsearch-hit-color: var(--c-text-light);
108
+ --docsearch-hit-active-color: var(--c-bg);
109
+ --docsearch-hit-background: var(--c-bg);
110
+ --docsearch-hit-shadow: 0 1px 3px 0 var(--c-border-dark);
111
+ --docsearch-footer-background: var(--c-bg);
112
+ }
113
+
114
+ // plugin-external-link-icon
115
+ .external-link-icon {
116
+ --external-link-icon-color: var(--c-text-quote);
117
+ }
118
+
119
+ // plugin-medium-zoom
120
+ .medium-zoom-overlay {
121
+ --medium-zoom-bg-color: var(--c-bg);
122
+ }
123
+
124
+ // plugin-nprogress
125
+ #nprogress {
126
+ --nprogress-color: var(--c-brand);
127
+ }
128
+
129
+ // plugin-pwa-popup
130
+ .pwa-popup {
131
+ --pwa-popup-text-color: var(--c-text);
132
+ --pwa-popup-bg-color: var(--c-bg);
133
+ --pwa-popup-border-color: var(--c-brand);
134
+ --pwa-popup-shadow: 0 4px 16px var(--c-brand);
135
+ --pwa-popup-btn-text-color: var(--c-bg);
136
+ --pwa-popup-btn-bg-color: var(--c-brand);
137
+ --pwa-popup-btn-hover-bg-color: var(--c-brand-light);
138
+ }
139
+
140
+ // plugin-search
141
+ .search-box {
142
+ --search-bg-color: var(--c-bg);
143
+ --search-accent-color: var(--c-brand);
144
+ --search-text-color: var(--c-text);
145
+ --search-border-color: var(--c-border);
146
+
147
+ --search-item-text-color: var(--c-text-lighter);
148
+ --search-item-focus-bg-color: var(--c-bg-light);
149
+ }
@@ -1,2 +1,3 @@
1
- export * from './resolveEditLink';
2
- export * from './resolveRepoType';
1
+ export * from './isActiveSidebarItem.js';
2
+ export * from './resolveEditLink.js';
3
+ export * from './resolveRepoType.js';
@@ -1,2 +1,3 @@
1
- export * from './resolveEditLink';
2
- export * from './resolveRepoType';
1
+ export * from './isActiveSidebarItem.js';
2
+ export * from './resolveEditLink.js';
3
+ export * from './resolveRepoType.js';
@@ -0,0 +1,3 @@
1
+ import type { RouteLocationNormalizedLoaded } from 'vue-router';
2
+ import type { ResolvedSidebarItem } from '../../shared/index.js';
3
+ export declare const isActiveSidebarItem: (item: ResolvedSidebarItem, route: RouteLocationNormalizedLoaded) => boolean;
@@ -0,0 +1,20 @@
1
+ const normalizePath = (path) => decodeURI(path)
2
+ .replace(/#.*$/, '')
3
+ .replace(/(index)?\.(md|html)$/, '');
4
+ const isActiveLink = (link, route) => {
5
+ if (route.hash === link) {
6
+ return true;
7
+ }
8
+ const currentPath = normalizePath(route.path);
9
+ const targetPath = normalizePath(link);
10
+ return currentPath === targetPath;
11
+ };
12
+ export const isActiveSidebarItem = (item, route) => {
13
+ if (item.link && isActiveLink(item.link, route)) {
14
+ return true;
15
+ }
16
+ if (item.children) {
17
+ return item.children.some((child) => isActiveSidebarItem(child, route));
18
+ }
19
+ return false;
20
+ };
@@ -1,9 +1,9 @@
1
- import type { RepoType } from './resolveRepoType';
1
+ import type { RepoType } from './resolveRepoType.js';
2
2
  export declare const editLinkPatterns: Record<Exclude<RepoType, null>, string>;
3
3
  export declare const resolveEditLink: ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }: {
4
4
  docsRepo: string;
5
5
  docsBranch: string;
6
6
  docsDir: string;
7
- filePathRelative: string;
7
+ filePathRelative: string | null;
8
8
  editLinkPattern?: string | undefined;
9
9
  }) => string | null;
@@ -1,23 +1,29 @@
1
- import { removeLeadingSlash, removeEndingSlash } from '@vuepress/shared';
2
- import { resolveRepoType } from './resolveRepoType';
1
+ import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from '@vuepress/shared';
2
+ import { resolveRepoType } from './resolveRepoType.js';
3
3
  export const editLinkPatterns = {
4
4
  GitHub: ':repo/edit/:branch/:path',
5
5
  GitLab: ':repo/-/edit/:branch/:path',
6
+ Gitee: ':repo/edit/:branch/:path',
6
7
  Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
7
8
  };
8
- export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
9
- const repoType = resolveRepoType(docsRepo);
10
- let pattern;
9
+ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
11
10
  if (editLinkPattern) {
12
- pattern = editLinkPattern;
11
+ return editLinkPattern;
13
12
  }
14
- else if (repoType !== null) {
15
- pattern = editLinkPatterns[repoType];
13
+ const repoType = resolveRepoType(docsRepo);
14
+ if (repoType !== null) {
15
+ return editLinkPatterns[repoType];
16
16
  }
17
+ return null;
18
+ };
19
+ export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
20
+ if (!filePathRelative)
21
+ return null;
22
+ const pattern = resolveEditLinkPatterns({ docsRepo, editLinkPattern });
17
23
  if (!pattern)
18
24
  return null;
19
25
  return pattern
20
- .replace(/:repo/, repoType === 'GitHub' ? `https://github.com/${docsRepo}` : docsRepo)
26
+ .replace(/:repo/, isLinkHttp(docsRepo) ? docsRepo : `https://github.com/${docsRepo}`)
21
27
  .replace(/:branch/, docsBranch)
22
28
  .replace(/:path/, removeLeadingSlash(`${removeEndingSlash(docsDir)}/${filePathRelative}`));
23
29
  };
@@ -1,2 +1,2 @@
1
- export declare type RepoType = 'GitHub' | 'GitLab' | 'Bitbucket' | null;
1
+ export type RepoType = 'GitHub' | 'GitLab' | 'Gitee' | 'Bitbucket' | null;
2
2
  export declare const resolveRepoType: (repo: string) => RepoType;
@@ -1,10 +1,12 @@
1
1
  import { isLinkHttp } from '@vuepress/shared';
2
2
  export const resolveRepoType = (repo) => {
3
- if (!isLinkHttp(repo))
3
+ if (!isLinkHttp(repo) || /github\.com/.test(repo))
4
4
  return 'GitHub';
5
5
  if (/bitbucket\.org/.test(repo))
6
6
  return 'Bitbucket';
7
7
  if (/gitlab\.com/.test(repo))
8
8
  return 'GitLab';
9
+ if (/gitee\.com/.test(repo))
10
+ return 'Gitee';
9
11
  return null;
10
12
  };
@@ -1,10 +1,10 @@
1
- import type { Theme, ThemeConfig } from '@vuepress/core';
2
- import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared';
3
- export interface DefaultThemeOptions extends ThemeConfig, DefaultThemeLocaleOptions {
1
+ import type { Theme } from '@vuepress/core';
2
+ import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared/index.js';
3
+ export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
4
4
  /**
5
5
  * To avoid confusion with the root `plugins` option,
6
6
  * we use `themePlugins`
7
7
  */
8
8
  themePlugins?: DefaultThemePluginsOptions;
9
9
  }
10
- export declare const defaultTheme: Theme<DefaultThemeOptions>;
10
+ export declare const defaultTheme: ({ themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
@@ -1,54 +1,117 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultTheme = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const utils_2 = require("./utils");
6
- const defaultTheme = ({ themePlugins = {}, ...localeOptions }) => {
7
- utils_2.assignDefaultLocaleOptions(localeOptions);
1
+ import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
2
+ import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
3
+ import { containerPlugin } from '@vuepress/plugin-container';
4
+ import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon';
5
+ import { gitPlugin } from '@vuepress/plugin-git';
6
+ import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
7
+ import { nprogressPlugin } from '@vuepress/plugin-nprogress';
8
+ import { palettePlugin } from '@vuepress/plugin-palette';
9
+ import { prismjsPlugin } from '@vuepress/plugin-prismjs';
10
+ import { themeDataPlugin } from '@vuepress/plugin-theme-data';
11
+ import { fs, getDirname, path } from '@vuepress/utils';
12
+ import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
13
+ const __dirname = getDirname(import.meta.url);
14
+ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
15
+ assignDefaultLocaleOptions(localeOptions);
8
16
  return {
9
17
  name: '@vuepress/theme-default',
10
- layouts: utils_1.path.resolve(__dirname, '../client/layouts'),
11
- clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
12
- clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
13
- // use the relative file path to generate edit link
14
- extendsPageData: ({ filePathRelative }) => ({ filePathRelative }),
18
+ templateBuild: path.resolve(__dirname, '../../templates/build.html'),
19
+ alias: {
20
+ // use alias to make all components replaceable
21
+ ...Object.fromEntries(fs
22
+ .readdirSync(path.resolve(__dirname, '../client/components'))
23
+ .filter((file) => file.endsWith('.vue'))
24
+ .map((file) => [
25
+ `@theme/${file}`,
26
+ path.resolve(__dirname, '../client/components', file),
27
+ ])),
28
+ },
29
+ clientConfigFile: path.resolve(__dirname, '../client/config.js'),
30
+ extendsPage: (page) => {
31
+ // save relative file path into page data to generate edit link
32
+ page.data.filePathRelative = page.filePathRelative;
33
+ // save title into route meta to generate navbar and sidebar
34
+ page.routeMeta.title = page.title;
35
+ },
15
36
  plugins: [
16
- [
17
- '@vuepress/active-header-links',
18
- utils_2.resolveActiveHeaderLinksPluginOptions(themePlugins),
19
- ],
20
- ['@vuepress/back-to-top', themePlugins.backToTop !== false],
21
- [
22
- '@vuepress/container',
23
- utils_2.resolveContainerPluginOptions(themePlugins, localeOptions, 'tip'),
24
- ],
25
- [
26
- '@vuepress/container',
27
- utils_2.resolveContainerPluginOptions(themePlugins, localeOptions, 'warning'),
28
- ],
29
- [
30
- '@vuepress/container',
31
- utils_2.resolveContainerPluginOptions(themePlugins, localeOptions, 'danger'),
32
- ],
33
- [
34
- '@vuepress/container',
35
- utils_2.resolveContainerPluginOptionsForDetails(themePlugins),
36
- ],
37
- [
38
- '@vuepress/container',
39
- utils_2.resolveContainerPluginOptionsForCodeGroup(themePlugins),
40
- ],
41
- [
42
- '@vuepress/container',
43
- utils_2.resolveContainerPluginOptionsForCodeGroupItem(themePlugins),
44
- ],
45
- ['@vuepress/git', utils_2.resolveGitPluginOptions(themePlugins, localeOptions)],
46
- ['@vuepress/medium-zoom', utils_2.resolveMediumZoomPluginOptions(themePlugins)],
47
- ['@vuepress/nprogress', themePlugins.nprogress !== false],
48
- ['@vuepress/palette', { preset: 'sass' }],
49
- ['@vuepress/prismjs', themePlugins.prismjs !== false],
50
- ['@vuepress/theme-data', { themeData: localeOptions }],
37
+ // @vuepress/plugin-active-header-link
38
+ themePlugins.activeHeaderLinks !== false
39
+ ? activeHeaderLinksPlugin({
40
+ headerLinkSelector: 'a.sidebar-item',
41
+ headerAnchorSelector: '.header-anchor',
42
+ // should greater than page transition duration
43
+ delay: 300,
44
+ })
45
+ : [],
46
+ // @vuepress/plugin-back-to-top
47
+ themePlugins.backToTop !== false ? backToTopPlugin() : [],
48
+ // @vuepress/plugin-container
49
+ themePlugins.container?.tip !== false
50
+ ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'tip'))
51
+ : [],
52
+ themePlugins.container?.warning !== false
53
+ ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'warning'))
54
+ : [],
55
+ themePlugins.container?.danger !== false
56
+ ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'danger'))
57
+ : [],
58
+ themePlugins.container?.details !== false
59
+ ? containerPlugin({
60
+ type: 'details',
61
+ before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
62
+ after: () => '</details>\n',
63
+ })
64
+ : [],
65
+ themePlugins.container?.codeGroup !== false
66
+ ? containerPlugin({
67
+ type: 'code-group',
68
+ before: () => `<CodeGroup>\n`,
69
+ after: () => '</CodeGroup>\n',
70
+ })
71
+ : [],
72
+ themePlugins.container?.codeGroupItem !== false
73
+ ? containerPlugin({
74
+ type: 'code-group-item',
75
+ before: (info) => `<CodeGroupItem title="${info}">\n`,
76
+ after: () => '</CodeGroupItem>\n',
77
+ })
78
+ : [],
79
+ // @vuepress/plugin-external-link-icon
80
+ themePlugins.externalLinkIcon !== false
81
+ ? externalLinkIconPlugin({
82
+ locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
83
+ result[key] = {
84
+ openInNewWindow: value.openInNewWindow ?? localeOptions.openInNewWindow,
85
+ };
86
+ return result;
87
+ }, {}),
88
+ })
89
+ : [],
90
+ // @vuepress/plugin-git
91
+ themePlugins.git !== false
92
+ ? gitPlugin({
93
+ createdTime: false,
94
+ updatedTime: localeOptions.lastUpdated !== false,
95
+ contributors: localeOptions.contributors !== false,
96
+ })
97
+ : [],
98
+ // @vuepress/plugin-medium-zoom
99
+ themePlugins.mediumZoom !== false
100
+ ? mediumZoomPlugin({
101
+ selector: '.theme-default-content > img, .theme-default-content :not(a) > img',
102
+ zoomOptions: {},
103
+ // should greater than page transition duration
104
+ delay: 300,
105
+ })
106
+ : [],
107
+ // @vuepress/plugin-nprogress
108
+ themePlugins.nprogress !== false ? nprogressPlugin() : [],
109
+ // @vuepress/plugin-palette
110
+ palettePlugin({ preset: 'sass' }),
111
+ // @vuepress/plugin-prismjs
112
+ themePlugins.prismjs !== false ? prismjsPlugin() : [],
113
+ // @vuepress/plugin-theme-data
114
+ themeDataPlugin({ themeData: localeOptions }),
51
115
  ],
52
116
  };
53
117
  };
54
- exports.defaultTheme = defaultTheme;
@@ -1,5 +1,5 @@
1
- import { defaultTheme } from './defaultTheme';
2
- export * from '../shared';
3
- export * from './defaultTheme';
4
- export * from './utils';
1
+ import { defaultTheme } from './defaultTheme.js';
2
+ export * from '../shared/index.js';
3
+ export * from './defaultTheme.js';
4
+ export * from './utils/index.js';
5
5
  export default defaultTheme;
package/lib/node/index.js CHANGED
@@ -1,17 +1,5 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- const defaultTheme_1 = require("./defaultTheme");
14
- __exportStar(require("../shared"), exports);
15
- __exportStar(require("./defaultTheme"), exports);
16
- __exportStar(require("./utils"), exports);
17
- exports.default = defaultTheme_1.defaultTheme;
1
+ import { defaultTheme } from './defaultTheme.js';
2
+ export * from '../shared/index.js';
3
+ export * from './defaultTheme.js';
4
+ export * from './utils/index.js';
5
+ export default defaultTheme;
@@ -1,5 +1,7 @@
1
- import type { DefaultThemeLocaleOptions } from '../../shared';
1
+ import type { DefaultThemeLocaleData, DefaultThemeLocaleOptions } from '../../shared/index.js';
2
+ export declare const DEFAULT_LOCALE_OPTIONS: DefaultThemeLocaleOptions;
3
+ export declare const DEFAULT_LOCALE_DATA: DefaultThemeLocaleData;
2
4
  /**
3
- * Assign default options to `themeConfig`
5
+ * Assign default options
4
6
  */
5
7
  export declare const assignDefaultLocaleOptions: (localeOptions: DefaultThemeLocaleOptions) => void;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assignDefaultLocaleOptions = void 0;
4
- const defaultLocaleOptions = {
1
+ export const DEFAULT_LOCALE_OPTIONS = {
2
+ // color mode
3
+ colorMode: 'auto',
4
+ colorModeSwitch: true,
5
5
  // navbar
6
6
  navbar: [],
7
7
  logo: null,
@@ -10,6 +10,7 @@ const defaultLocaleOptions = {
10
10
  selectLanguageAriaLabel: 'Select language',
11
11
  // sidebar
12
12
  sidebar: 'auto',
13
+ sidebarDepth: 2,
13
14
  // page meta
14
15
  editLink: true,
15
16
  editLinkText: 'Edit this page',
@@ -25,19 +26,19 @@ const defaultLocaleOptions = {
25
26
  `Looks like we've got some broken links.`,
26
27
  ],
27
28
  backToHome: 'Take me home',
28
- // `<OutboundLink>` sr-only
29
+ // a11y
29
30
  openInNewWindow: 'open in new window',
31
+ toggleColorMode: 'toggle color mode',
32
+ toggleSidebar: 'toggle sidebar',
30
33
  };
31
- const defaultLocaleData = {
34
+ export const DEFAULT_LOCALE_DATA = {
32
35
  // navbar
33
36
  selectLanguageName: 'English',
34
- // custom block
35
- danger: 'WARNING',
36
37
  };
37
38
  /**
38
- * Assign default options to `themeConfig`
39
+ * Assign default options
39
40
  */
40
- const assignDefaultLocaleOptions = (localeOptions) => {
41
+ export const assignDefaultLocaleOptions = (localeOptions) => {
41
42
  if (!localeOptions.locales) {
42
43
  localeOptions.locales = {};
43
44
  }
@@ -45,12 +46,11 @@ const assignDefaultLocaleOptions = (localeOptions) => {
45
46
  localeOptions.locales['/'] = {};
46
47
  }
47
48
  Object.assign(localeOptions, {
48
- ...defaultLocaleOptions,
49
+ ...DEFAULT_LOCALE_OPTIONS,
49
50
  ...localeOptions,
50
51
  });
51
52
  Object.assign(localeOptions.locales['/'], {
52
- ...defaultLocaleData,
53
+ ...DEFAULT_LOCALE_DATA,
53
54
  ...localeOptions.locales['/'],
54
55
  });
55
56
  };
56
- exports.assignDefaultLocaleOptions = assignDefaultLocaleOptions;
@@ -1,5 +1,2 @@
1
- export * from './assignDefaultLocaleOptions';
2
- export * from './resolveActiveHeaderLinksPluginOptions';
3
- export * from './resolveContainerPluginOptions';
4
- export * from './resolveGitPluginOptions';
5
- export * from './resolveMediumZoomPluginOptions';
1
+ export * from './assignDefaultLocaleOptions.js';
2
+ export * from './resolveContainerPluginOptions.js';
@@ -1,17 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./assignDefaultLocaleOptions"), exports);
14
- __exportStar(require("./resolveActiveHeaderLinksPluginOptions"), exports);
15
- __exportStar(require("./resolveContainerPluginOptions"), exports);
16
- __exportStar(require("./resolveGitPluginOptions"), exports);
17
- __exportStar(require("./resolveMediumZoomPluginOptions"), exports);
1
+ export * from './assignDefaultLocaleOptions.js';
2
+ export * from './resolveContainerPluginOptions.js';
@@ -1,26 +1,8 @@
1
1
  import type { ContainerPluginOptions } from '@vuepress/plugin-container';
2
- import type { DefaultThemePluginsOptions, DefaultThemeData } from '../../shared';
2
+ import type { DefaultThemeData } from '../../shared/index.js';
3
3
  /**
4
4
  * Resolve options for @vuepress/plugin-container
5
5
  *
6
6
  * For custom containers default title
7
7
  */
8
- export declare const resolveContainerPluginOptions: (themePlugins: DefaultThemePluginsOptions, localeOptions: DefaultThemeData, type: 'tip' | 'warning' | 'danger') => ContainerPluginOptions | boolean;
9
- /**
10
- * Resolve options for @vuepress/plugin-container
11
- *
12
- * For details container
13
- */
14
- export declare const resolveContainerPluginOptionsForDetails: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
15
- /**
16
- * Resolve options for @vuepress/plugin-container
17
- *
18
- * For code-group container
19
- */
20
- export declare const resolveContainerPluginOptionsForCodeGroup: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
21
- /**
22
- * Resolve options for @vuepress/plugin-container
23
- *
24
- * For code-group-item block
25
- */
26
- export declare const resolveContainerPluginOptionsForCodeGroupItem: (themePlugins: DefaultThemePluginsOptions) => ContainerPluginOptions | boolean;
8
+ export declare const resolveContainerPluginOptions: (localeOptions: DefaultThemeData, type: 'tip' | 'warning' | 'danger') => ContainerPluginOptions;