@vuepress/theme-default 2.0.0-rc.6 → 2.0.0-rc.60

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 (141) hide show
  1. package/lib/client/components/VPDarkIcon.vue +8 -0
  2. package/lib/client/components/VPDropdownTransition.vue +36 -0
  3. package/lib/client/components/VPEditIcon.vue +12 -0
  4. package/lib/client/components/VPHome.vue +38 -0
  5. package/lib/client/components/VPHomeFeatures.vue +66 -0
  6. package/lib/client/components/{HomeFooter.vue → VPHomeFooter.vue} +17 -2
  7. package/lib/client/components/{HomeHero.vue → VPHomeHero.vue} +113 -19
  8. package/lib/client/components/VPLightIcon.vue +28 -0
  9. package/lib/client/components/VPNavbar.vue +134 -0
  10. package/lib/client/components/{NavbarBrand.vue → VPNavbarBrand.vue} +40 -7
  11. package/lib/client/components/VPNavbarDropdown.vue +334 -0
  12. package/lib/client/components/VPNavbarItems.vue +111 -0
  13. package/lib/client/components/VPPage.vue +72 -0
  14. package/lib/client/components/VPPageMeta.vue +134 -0
  15. package/lib/client/components/VPPageNav.vue +118 -0
  16. package/lib/client/components/VPSidebar.vue +113 -0
  17. package/lib/client/components/VPSidebarItem.vue +174 -0
  18. package/lib/client/components/{SidebarItems.vue → VPSidebarItems.vue} +32 -7
  19. package/lib/client/components/VPToggleColorModeButton.vue +55 -0
  20. package/lib/client/components/VPToggleSidebarButton.vue +92 -0
  21. package/lib/client/components/global/Badge.vue +84 -18
  22. package/lib/client/components/global/index.d.ts +1 -3
  23. package/lib/client/components/global/index.js +1 -3
  24. package/lib/client/composables/index.d.ts +8 -0
  25. package/lib/client/composables/index.js +8 -0
  26. package/lib/client/composables/useContributors.d.ts +3 -0
  27. package/lib/client/composables/useContributors.js +14 -0
  28. package/lib/client/composables/useDarkMode.d.ts +0 -1
  29. package/lib/client/composables/useDarkMode.js +16 -13
  30. package/lib/client/composables/useEditLink.d.ts +3 -0
  31. package/lib/client/composables/useEditLink.js +31 -0
  32. package/lib/client/composables/useLastUpdated.d.ts +2 -0
  33. package/lib/client/composables/useLastUpdated.js +17 -0
  34. package/lib/client/composables/useNavbarConfig.d.ts +3 -0
  35. package/lib/client/composables/useNavbarConfig.js +27 -0
  36. package/lib/client/composables/useNavbarRepo.d.ts +6 -0
  37. package/lib/client/composables/useNavbarRepo.js +38 -0
  38. package/lib/client/composables/useNavbarSelectLanguage.d.ts +6 -0
  39. package/lib/client/composables/useNavbarSelectLanguage.js +59 -0
  40. package/lib/client/composables/useNavigate.d.ts +1 -0
  41. package/lib/client/composables/useNavigate.js +22 -0
  42. package/lib/client/composables/useRelatedLinks.d.ts +8 -0
  43. package/lib/client/composables/useRelatedLinks.js +91 -0
  44. package/lib/client/composables/useScrollPromise.js +3 -1
  45. package/lib/client/composables/useSidebarItems.d.ts +28 -23
  46. package/lib/client/composables/useSidebarItems.js +120 -84
  47. package/lib/client/composables/useUpdateDeviceStatus.d.ts +1 -1
  48. package/lib/client/composables/useUpdateDeviceStatus.js +10 -5
  49. package/lib/client/config.d.ts +3 -2
  50. package/lib/client/config.js +6 -23
  51. package/lib/client/index.d.ts +2 -1
  52. package/lib/client/index.js +0 -1
  53. package/lib/client/layouts/Layout.vue +139 -34
  54. package/lib/client/layouts/NotFound.vue +17 -5
  55. package/lib/client/shim.d.ts +12 -3
  56. package/lib/client/styles/_mixins.scss +4 -4
  57. package/lib/client/styles/_variables.module.scss +1 -1
  58. package/lib/client/styles/_variables.scss +2 -1
  59. package/lib/client/styles/arrow.scss +18 -24
  60. package/lib/client/styles/code-group.scss +35 -30
  61. package/lib/client/styles/content/code.scss +23 -0
  62. package/lib/client/styles/content/index.scss +3 -0
  63. package/lib/client/styles/content/normalize.scss +39 -0
  64. package/lib/client/styles/{toc.scss → content/toc.scss} +1 -1
  65. package/lib/client/styles/external-link-icon.scss +36 -0
  66. package/lib/client/styles/index.scss +3 -13
  67. package/lib/client/styles/layout.scss +3 -199
  68. package/lib/client/styles/normalize.scss +1 -194
  69. package/lib/client/styles/plugins.scss +28 -0
  70. package/lib/client/styles/vars-dark.scss +20 -58
  71. package/lib/client/styles/vars.scss +53 -129
  72. package/lib/client/typings.d.ts +13 -0
  73. package/lib/client/typings.js +1 -0
  74. package/lib/client/utils/getAutoLink.d.ts +9 -0
  75. package/lib/client/utils/getAutoLink.js +17 -0
  76. package/lib/client/utils/index.d.ts +3 -2
  77. package/lib/client/utils/index.js +3 -2
  78. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -3
  79. package/lib/client/utils/isActiveSidebarItem.js +3 -3
  80. package/lib/client/utils/isLinkInternal.d.ts +1 -0
  81. package/lib/client/utils/isLinkInternal.js +2 -0
  82. package/lib/client/utils/resolveEditLink.d.ts +1 -1
  83. package/lib/client/utils/resolvePrefix.d.ts +1 -0
  84. package/lib/client/utils/resolvePrefix.js +4 -0
  85. package/lib/client/utils/resolveRepoType.d.ts +1 -1
  86. package/lib/client/utils/resolveRepoType.js +4 -4
  87. package/lib/node/defaultTheme.d.ts +2 -1
  88. package/lib/node/defaultTheme.js +40 -49
  89. package/lib/node/index.d.ts +2 -3
  90. package/lib/node/index.js +0 -3
  91. package/lib/node/typings.d.ts +58 -0
  92. package/lib/node/typings.js +1 -0
  93. package/lib/node/utils/assignDefaultLocaleOptions.js +3 -7
  94. package/lib/node/utils/index.d.ts +1 -1
  95. package/lib/node/utils/index.js +1 -1
  96. package/lib/node/utils/resolveMarkdownHintLocales.d.ts +9 -0
  97. package/lib/node/utils/resolveMarkdownHintLocales.js +19 -0
  98. package/lib/shared/index.d.ts +5 -3
  99. package/lib/shared/index.js +1 -3
  100. package/lib/shared/nav.d.ts +19 -30
  101. package/lib/shared/navbar.d.ts +21 -0
  102. package/lib/shared/navbar.js +1 -0
  103. package/lib/shared/options.d.ts +36 -65
  104. package/lib/shared/page.d.ts +9 -6
  105. package/lib/shared/sidebar.d.ts +26 -0
  106. package/lib/shared/sidebar.js +1 -0
  107. package/package.json +30 -28
  108. package/templates/build.html +14 -8
  109. package/lib/client/components/AutoLink.vue +0 -113
  110. package/lib/client/components/DropdownTransition.vue +0 -25
  111. package/lib/client/components/Home.vue +0 -15
  112. package/lib/client/components/HomeContent.vue +0 -5
  113. package/lib/client/components/HomeFeatures.vue +0 -22
  114. package/lib/client/components/Navbar.vue +0 -79
  115. package/lib/client/components/NavbarDropdown.vue +0 -126
  116. package/lib/client/components/NavbarItems.vue +0 -199
  117. package/lib/client/components/Page.vue +0 -31
  118. package/lib/client/components/PageMeta.vue +0 -124
  119. package/lib/client/components/PageNav.vue +0 -122
  120. package/lib/client/components/Sidebar.vue +0 -18
  121. package/lib/client/components/SidebarItem.vue +0 -87
  122. package/lib/client/components/ToggleColorModeButton.vue +0 -57
  123. package/lib/client/components/ToggleSidebarButton.vue +0 -24
  124. package/lib/client/components/global/CodeGroup.d.ts +0 -6
  125. package/lib/client/components/global/CodeGroup.js +0 -120
  126. package/lib/client/components/global/CodeGroupItem.vue +0 -27
  127. package/lib/client/styles/badge.scss +0 -36
  128. package/lib/client/styles/code.scss +0 -263
  129. package/lib/client/styles/custom-container.scss +0 -142
  130. package/lib/client/styles/home.scss +0 -168
  131. package/lib/client/styles/navbar-dropdown.scss +0 -183
  132. package/lib/client/styles/navbar.scss +0 -197
  133. package/lib/client/styles/page.scss +0 -87
  134. package/lib/client/styles/sidebar.scss +0 -134
  135. package/lib/client/styles/transitions.scss +0 -22
  136. package/lib/client/utils/getNavLink.d.ts +0 -15
  137. package/lib/client/utils/getNavLink.js +0 -18
  138. package/lib/client/utils/getResolveRouteWithRedirect.d.ts +0 -5
  139. package/lib/client/utils/getResolveRouteWithRedirect.js +0 -22
  140. package/lib/node/utils/resolveContainerPluginOptions.d.ts +0 -8
  141. package/lib/node/utils/resolveContainerPluginOptions.js +0 -17
@@ -1,9 +1,11 @@
1
+ import { addViteOptimizeDepsExclude } from '@vuepress/helper';
1
2
  import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
2
3
  import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
3
- import { containerPlugin } from '@vuepress/plugin-container';
4
4
  import { copyCodePlugin } from '@vuepress/plugin-copy-code';
5
- import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon';
6
5
  import { gitPlugin } from '@vuepress/plugin-git';
6
+ import { linksCheckPlugin } from '@vuepress/plugin-links-check';
7
+ import { markdownHintPlugin } from '@vuepress/plugin-markdown-hint';
8
+ import { markdownTabPlugin } from '@vuepress/plugin-markdown-tab';
7
9
  import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
8
10
  import { nprogressPlugin } from '@vuepress/plugin-nprogress';
9
11
  import { palettePlugin } from '@vuepress/plugin-palette';
@@ -13,7 +15,7 @@ import { sitemapPlugin } from '@vuepress/plugin-sitemap';
13
15
  import { themeDataPlugin } from '@vuepress/plugin-theme-data';
14
16
  import { isPlainObject } from 'vuepress/shared';
15
17
  import { fs, getDirname, path } from 'vuepress/utils';
16
- import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
18
+ import { assignDefaultLocaleOptions, resolveMarkdownHintLocales, } from './utils/index.js';
17
19
  const __dirname = getDirname(import.meta.url);
18
20
  export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } = {}) => {
19
21
  assignDefaultLocaleOptions(localeOptions);
@@ -29,8 +31,20 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
29
31
  `@theme/${file}`,
30
32
  path.resolve(__dirname, '../client/components', file),
31
33
  ])),
34
+ // use alias to make all composables replaceable
35
+ ...Object.fromEntries(fs
36
+ .readdirSync(path.resolve(__dirname, '../client/composables'))
37
+ .filter((file) => file.endsWith('.js'))
38
+ .map((file) => [
39
+ `@theme/${file.substring(0, file.length - 3)}`,
40
+ path.resolve(__dirname, '../client/composables', file),
41
+ ])),
32
42
  },
33
43
  clientConfigFile: path.resolve(__dirname, '../client/config.js'),
44
+ extendsBundlerOptions: (bundlerOptions, app) => {
45
+ // ensure theme alias is not optimized by Vite
46
+ addViteOptimizeDepsExclude(bundlerOptions, app, '@theme');
47
+ },
34
48
  extendsPage: (page) => {
35
49
  // save relative file path into page data to generate edit link
36
50
  page.data.filePathRelative = page.filePathRelative;
@@ -41,14 +55,14 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
41
55
  // @vuepress/plugin-active-header-link
42
56
  themePlugins.activeHeaderLinks !== false
43
57
  ? activeHeaderLinksPlugin({
44
- headerLinkSelector: 'a.sidebar-item',
45
- headerAnchorSelector: '.header-anchor',
46
58
  // should greater than page transition duration
47
59
  delay: 300,
48
60
  })
49
61
  : [],
50
62
  // @vuepress/plugin-back-to-top
51
- themePlugins.backToTop !== false ? backToTopPlugin() : [],
63
+ themePlugins.backToTop !== false
64
+ ? backToTopPlugin(isPlainObject(themePlugins.backToTop) ? themePlugins.backToTop : {})
65
+ : [],
52
66
  // @vuepress/plugin-copy-code
53
67
  themePlugins.copyCode !== false
54
68
  ? copyCodePlugin({
@@ -57,46 +71,11 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
57
71
  : {}),
58
72
  })
59
73
  : [],
60
- // @vuepress/plugin-container
61
- themePlugins.container?.tip !== false
62
- ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'tip'))
63
- : [],
64
- themePlugins.container?.warning !== false
65
- ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'warning'))
66
- : [],
67
- themePlugins.container?.danger !== false
68
- ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'danger'))
69
- : [],
70
- themePlugins.container?.details !== false
71
- ? containerPlugin({
72
- type: 'details',
73
- before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
74
- after: () => '</details>\n',
75
- })
76
- : [],
77
- themePlugins.container?.codeGroup !== false
78
- ? containerPlugin({
79
- type: 'code-group',
80
- before: () => `<CodeGroup>\n`,
81
- after: () => '</CodeGroup>\n',
82
- })
83
- : [],
84
- themePlugins.container?.codeGroupItem !== false
85
- ? containerPlugin({
86
- type: 'code-group-item',
87
- before: (info) => `<CodeGroupItem title="${info}">\n`,
88
- after: () => '</CodeGroupItem>\n',
89
- })
90
- : [],
91
- // @vuepress/plugin-external-link-icon
92
- themePlugins.externalLinkIcon !== false
93
- ? externalLinkIconPlugin({
94
- locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
95
- result[key] = {
96
- openInNewWindow: value.openInNewWindow ?? localeOptions.openInNewWindow,
97
- };
98
- return result;
99
- }, {}),
74
+ // @vuepress/plugin-markdown-container
75
+ themePlugins.hint !== false
76
+ ? markdownHintPlugin({
77
+ locales: resolveMarkdownHintLocales(localeOptions),
78
+ ...(isPlainObject(themePlugins.hint) ? themePlugins.hint : {}),
100
79
  })
101
80
  : [],
102
81
  // @vuepress/plugin-git
@@ -107,11 +86,15 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
107
86
  contributors: localeOptions.contributors !== false,
108
87
  })
109
88
  : [],
89
+ // @vuepress/plugin-links-check
90
+ themePlugins.linksCheck !== false
91
+ ? linksCheckPlugin(isPlainObject(themePlugins.linksCheck)
92
+ ? themePlugins.linksCheck
93
+ : {})
94
+ : [],
110
95
  // @vuepress/plugin-medium-zoom
111
96
  themePlugins.mediumZoom !== false
112
97
  ? mediumZoomPlugin({
113
- selector: '.theme-default-content > img, .theme-default-content :not(a) > img',
114
- zoomOptions: {},
115
98
  // should greater than page transition duration
116
99
  delay: 300,
117
100
  })
@@ -121,7 +104,9 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
121
104
  // @vuepress/plugin-palette
122
105
  palettePlugin({ preset: 'sass' }),
123
106
  // @vuepress/plugin-prismjs
124
- themePlugins.prismjs !== false ? prismjsPlugin() : [],
107
+ themePlugins.prismjs !== false
108
+ ? prismjsPlugin(isPlainObject(themePlugins.prismjs) ? themePlugins.prismjs : {})
109
+ : [],
125
110
  // @vuepress/plugin-seo
126
111
  hostname && themePlugins.seo !== false
127
112
  ? seoPlugin({
@@ -138,6 +123,12 @@ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } =
138
123
  : {}),
139
124
  })
140
125
  : [],
126
+ // @vuepress/plugin-markdown-tab
127
+ themePlugins.tab !== false
128
+ ? markdownTabPlugin(isPlainObject(themePlugins.tab)
129
+ ? themePlugins.tab
130
+ : { codeTabs: true, tabs: true })
131
+ : [],
141
132
  // @vuepress/plugin-theme-data
142
133
  themeDataPlugin({ themeData: localeOptions }),
143
134
  ],
@@ -1,5 +1,4 @@
1
- import { defaultTheme } from './defaultTheme.js';
2
- export * from '../shared/index.js';
3
1
  export * from './defaultTheme.js';
2
+ export type * from './typings.js';
4
3
  export * from './utils/index.js';
5
- export default defaultTheme;
4
+ export type * from '../shared/index.js';
package/lib/node/index.js CHANGED
@@ -1,5 +1,2 @@
1
- import { defaultTheme } from './defaultTheme.js';
2
- export * from '../shared/index.js';
3
1
  export * from './defaultTheme.js';
4
2
  export * from './utils/index.js';
5
- export default defaultTheme;
@@ -0,0 +1,58 @@
1
+ import type { BackToTopPluginOptions } from '@vuepress/plugin-back-to-top';
2
+ import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code';
3
+ import type { LinksCheckPluginOptions } from '@vuepress/plugin-links-check';
4
+ import type { MarkdownHintPluginOptions } from '@vuepress/plugin-markdown-hint';
5
+ import type { MarkdownTabPluginOptions } from '@vuepress/plugin-markdown-tab';
6
+ import type { PrismjsPluginOptions } from '@vuepress/plugin-prismjs';
7
+ import type { SeoPluginOptions } from '@vuepress/plugin-seo';
8
+ import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
9
+ export interface DefaultThemePluginsOptions {
10
+ /**
11
+ * Enable @vuepress/plugin-active-header-links or not
12
+ */
13
+ activeHeaderLinks?: boolean;
14
+ /**
15
+ * Enable @vuepress/plugin-back-to-top or not
16
+ */
17
+ backToTop?: BackToTopPluginOptions | boolean;
18
+ /**
19
+ * Enable @vuepress/plugin-copy-code or not
20
+ */
21
+ copyCode?: CopyCodePluginOptions | boolean;
22
+ /**
23
+ * Enable @vuepress/plugin-git or not
24
+ */
25
+ git?: boolean;
26
+ /**
27
+ * Enable @vuepress/plugin-markdown-hint or not
28
+ */
29
+ hint?: MarkdownHintPluginOptions | boolean;
30
+ /**
31
+ * Enable @vuepress/plugin-links-check or not
32
+ */
33
+ linksCheck?: LinksCheckPluginOptions | boolean;
34
+ /**
35
+ * Enable @vuepress/plugin-medium-zoom or not
36
+ */
37
+ mediumZoom?: boolean;
38
+ /**
39
+ * Enable @vuepress/plugin-nprogress or not
40
+ */
41
+ nprogress?: boolean;
42
+ /**
43
+ * Enable @vuepress/plugin-prismjs or not
44
+ */
45
+ prismjs?: PrismjsPluginOptions | boolean;
46
+ /**
47
+ * Enable @vuepress/plugin-seo or not
48
+ */
49
+ seo?: Partial<SeoPluginOptions> | boolean;
50
+ /**
51
+ * Enable @vuepress/plugin-sitemap or not
52
+ */
53
+ sitemap?: Partial<SitemapPluginOptions> | boolean;
54
+ /**
55
+ * Enable @vuepress/plugin-markdown-tab or not
56
+ */
57
+ tab?: MarkdownTabPluginOptions | boolean;
58
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -9,7 +9,7 @@ export const DEFAULT_LOCALE_OPTIONS = {
9
9
  selectLanguageText: 'Languages',
10
10
  selectLanguageAriaLabel: 'Select language',
11
11
  // sidebar
12
- sidebar: 'auto',
12
+ sidebar: 'heading',
13
13
  sidebarDepth: 2,
14
14
  // page meta
15
15
  editLink: true,
@@ -39,16 +39,12 @@ export const DEFAULT_LOCALE_DATA = {
39
39
  * Assign default options
40
40
  */
41
41
  export const assignDefaultLocaleOptions = (localeOptions) => {
42
- if (!localeOptions.locales) {
43
- localeOptions.locales = {};
44
- }
45
- if (!localeOptions.locales['/']) {
46
- localeOptions.locales['/'] = {};
47
- }
42
+ localeOptions.locales ??= {};
48
43
  Object.assign(localeOptions, {
49
44
  ...DEFAULT_LOCALE_OPTIONS,
50
45
  ...localeOptions,
51
46
  });
47
+ localeOptions.locales['/'] ??= {};
52
48
  Object.assign(localeOptions.locales['/'], {
53
49
  ...DEFAULT_LOCALE_DATA,
54
50
  ...localeOptions.locales['/'],
@@ -1,2 +1,2 @@
1
1
  export * from './assignDefaultLocaleOptions.js';
2
- export * from './resolveContainerPluginOptions.js';
2
+ export * from './resolveMarkdownHintLocales.js';
@@ -1,2 +1,2 @@
1
1
  export * from './assignDefaultLocaleOptions.js';
2
- export * from './resolveContainerPluginOptions.js';
2
+ export * from './resolveMarkdownHintLocales.js';
@@ -0,0 +1,9 @@
1
+ import type { MarkdownHintPluginLocaleData } from '@vuepress/plugin-markdown-hint';
2
+ import type { LocaleConfig } from 'vuepress/shared';
3
+ import type { DefaultThemeData } from '../../shared/index.js';
4
+ /**
5
+ * Resolve options for @vuepress/plugin-markdown-container
6
+ *
7
+ * For custom containers default title
8
+ */
9
+ export declare const resolveMarkdownHintLocales: (localeOptions: DefaultThemeData) => LocaleConfig<MarkdownHintPluginLocaleData>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Resolve options for @vuepress/plugin-markdown-container
3
+ *
4
+ * For custom containers default title
5
+ */
6
+ export const resolveMarkdownHintLocales = (localeOptions) => Object.entries(localeOptions.locales ?? {}).reduce((result, [key, value]) => {
7
+ result[key] = {};
8
+ if (value.tip)
9
+ result[key].tip = value.tip;
10
+ if (value.warning)
11
+ result[key].warning = value.warning;
12
+ if (value.danger)
13
+ result[key].caution = value.danger;
14
+ if (value.important)
15
+ result[key].important = value.important;
16
+ if (value.note)
17
+ result[key].note = value.note;
18
+ return result;
19
+ }, {});
@@ -1,3 +1,5 @@
1
- export * from './nav.js';
2
- export * from './options.js';
3
- export * from './page.js';
1
+ export type * from './nav.js';
2
+ export type * from './navbar.js';
3
+ export type * from './options.js';
4
+ export type * from './page.js';
5
+ export type * from './sidebar.js';
@@ -1,3 +1 @@
1
- export * from './nav.js';
2
- export * from './options.js';
3
- export * from './page.js';
1
+ export {};
@@ -1,43 +1,32 @@
1
1
  /**
2
2
  * Base nav item, displayed as text
3
3
  */
4
- export interface NavItem {
4
+ export interface NavItemOptions {
5
5
  text: string;
6
6
  ariaLabel?: string;
7
7
  }
8
8
  /**
9
- * Base nav group, has nav items children
9
+ * Options for `<AutoLink>`
10
10
  */
11
- export interface NavGroup<T> extends NavItem {
12
- children: T[];
13
- }
14
- /**
15
- * Props for `<AutoLink>`
16
- */
17
- export interface NavLink extends NavItem {
11
+ export interface AutoLinkOptions extends NavItemOptions {
12
+ /**
13
+ * Link of item
14
+ */
18
15
  link: string;
16
+ /**
17
+ * Rel of `<a>` tag
18
+ */
19
19
  rel?: string;
20
+ /**
21
+ * Target of `<a>` tag
22
+ */
20
23
  target?: string;
24
+ /**
25
+ * Regexp mode to be active
26
+ */
21
27
  activeMatch?: string;
28
+ /**
29
+ * Whether it's active only when exact match
30
+ */
31
+ exact?: boolean;
22
32
  }
23
- /**
24
- * Navbar types
25
- */
26
- export type NavbarItem = NavLink;
27
- export type NavbarGroup = NavGroup<NavbarGroup | NavbarItem | string>;
28
- export type NavbarConfig = (NavbarItem | NavbarGroup | string)[];
29
- export type ResolvedNavbarItem = NavbarItem | NavGroup<ResolvedNavbarItem>;
30
- /**
31
- * Sidebar types
32
- */
33
- export type SidebarItem = NavItem & Partial<NavLink>;
34
- export type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | string> & {
35
- collapsible?: boolean;
36
- };
37
- export type SidebarConfigArray = (SidebarItem | SidebarGroup | string)[];
38
- export type SidebarConfigObjectItem = SidebarConfigArray | 'heading';
39
- export type SidebarConfigObject = Record<string, SidebarConfigObjectItem>;
40
- export type SidebarConfig = SidebarConfigArray | SidebarConfigObject;
41
- export type ResolvedSidebarItem = SidebarItem & Partial<NavGroup<ResolvedSidebarItem>> & {
42
- collapsible?: boolean;
43
- };
@@ -0,0 +1,21 @@
1
+ import type { AutoLinkOptions, NavItemOptions } from './nav.js';
2
+ /**
3
+ * Base nav group, has nav items children
4
+ */
5
+ export interface NavGroup<T> extends NavItemOptions {
6
+ /**
7
+ * Link prefix of current group
8
+ */
9
+ prefix?: string;
10
+ /**
11
+ * Link of current group
12
+ */
13
+ link?: string;
14
+ /**
15
+ * Children of current group
16
+ */
17
+ children: T[];
18
+ }
19
+ export type NavbarLinkOptions = AutoLinkOptions | string;
20
+ export type NavbarGroupOptions = NavGroup<NavbarLinkOptions | NavGroup<NavbarLinkOptions>>;
21
+ export type NavbarOptions = (NavbarGroupOptions | NavbarLinkOptions)[] | false;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,62 +1,7 @@
1
- import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code';
2
- import type { SeoPluginOptions } from '@vuepress/plugin-seo';
3
- import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
4
1
  import type { ThemeData } from '@vuepress/plugin-theme-data';
5
2
  import type { LocaleData } from 'vuepress/shared';
6
- import type { NavbarConfig, SidebarConfig } from './nav.js';
7
- export interface DefaultThemePluginsOptions {
8
- /**
9
- * Enable @vuepress/plugin-active-header-links or not
10
- */
11
- activeHeaderLinks?: boolean;
12
- /**
13
- * Enable @vuepress/plugin-back-to-top or not
14
- */
15
- backToTop?: boolean;
16
- /**
17
- * Enable @vuepress/plugin-container or not
18
- */
19
- container?: {
20
- tip?: boolean;
21
- warning?: boolean;
22
- danger?: boolean;
23
- details?: boolean;
24
- codeGroup?: boolean;
25
- codeGroupItem?: boolean;
26
- };
27
- /**
28
- * Enable @vuepress/plugin-copy-code or not
29
- */
30
- copyCode?: CopyCodePluginOptions | boolean;
31
- /**
32
- * Enable @vuepress/plugin-external-link-icon or not
33
- */
34
- externalLinkIcon?: boolean;
35
- /**
36
- * Enable @vuepress/plugin-git or not
37
- */
38
- git?: boolean;
39
- /**
40
- * Enable @vuepress/plugin-medium-zoom or not
41
- */
42
- mediumZoom?: boolean;
43
- /**
44
- * Enable @vuepress/plugin-nprogress or not
45
- */
46
- nprogress?: boolean;
47
- /**
48
- * Enable @vuepress/plugin-prismjs or not
49
- */
50
- prismjs?: boolean;
51
- /**
52
- * Enable @vuepress/plugin-seo or not
53
- */
54
- seo?: Partial<SeoPluginOptions> | boolean;
55
- /**
56
- * Enable @vuepress/plugin-sitemap or not
57
- */
58
- sitemap?: Partial<SitemapPluginOptions> | boolean;
59
- }
3
+ import type { NavbarOptions } from './navbar.js';
4
+ import type { SidebarOptions } from './sidebar.js';
60
5
  export type DefaultThemeLocaleOptions = DefaultThemeData;
61
6
  export type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
62
7
  export interface DefaultThemeLocaleData extends LocaleData {
@@ -72,6 +17,12 @@ export interface DefaultThemeLocaleData extends LocaleData {
72
17
  * @default true
73
18
  */
74
19
  colorModeSwitch?: boolean;
20
+ /**
21
+ * Whether show external link icon
22
+ *
23
+ * @default true
24
+ */
25
+ externalLinkIcon?: boolean;
75
26
  /**
76
27
  * Home path of current locale
77
28
  *
@@ -83,40 +34,40 @@ export interface DefaultThemeLocaleData extends LocaleData {
83
34
  *
84
35
  * Set to `false` to disable navbar in current locale
85
36
  */
86
- navbar?: false | NavbarConfig;
37
+ navbar?: NavbarOptions | false;
87
38
  /**
88
39
  * Navbar label used for screen readers using the `aria-label` attribute
89
40
  */
90
- navbarLabel?: null | string;
41
+ navbarLabel?: string | null;
91
42
  /**
92
43
  * Page navbar label used for screen readers using the `aria-label` attribute
93
44
  */
94
- pageNavbarLabel?: null | string;
45
+ pageNavbarLabel?: string | null;
95
46
  /**
96
47
  * Navbar logo config
97
48
  *
98
49
  * Logo to display in navbar
99
50
  */
100
- logo?: null | string;
51
+ logo?: string | null;
101
52
  /**
102
53
  * Navbar logo config for dark mode
103
54
  *
104
55
  * Logo to display in navbar in dark mode
105
56
  */
106
- logoDark?: null | string;
57
+ logoDark?: string | null;
107
58
  /**
108
59
  * The alt text of navbar logo.
109
60
  * Defaults to the site title if not specified.
110
61
  * If the value is the same as the site title, the site title rendered in the navbar will be
111
62
  * hidden from screen readers to avoid duplication.
112
63
  */
113
- logoAlt?: null | string;
64
+ logoAlt?: string | null;
114
65
  /**
115
66
  * Navbar repository config
116
67
  *
117
68
  * Used for the repository link of navbar
118
69
  */
119
- repo?: null | string;
70
+ repo?: string | null;
120
71
  /**
121
72
  * Navbar repository config
122
73
  *
@@ -148,7 +99,7 @@ export interface DefaultThemeLocaleData extends LocaleData {
148
99
  *
149
100
  * Set to `false` to disable sidebar in current locale
150
101
  */
151
- sidebar?: 'auto' | false | SidebarConfig;
102
+ sidebar?: SidebarOptions | false;
152
103
  /**
153
104
  * Sidebar depth
154
105
  *
@@ -246,6 +197,18 @@ export interface DefaultThemeLocaleData extends LocaleData {
246
197
  * Default title of DANGER custom block
247
198
  */
248
199
  danger?: string;
200
+ /**
201
+ * Custom block config
202
+ *
203
+ * Default title of IMPORTANT custom block
204
+ */
205
+ important?: string;
206
+ /**
207
+ * Custom block config
208
+ *
209
+ * Default title of NOTE custom block
210
+ */
211
+ note?: string;
249
212
  /**
250
213
  * 404 page config
251
214
  *
@@ -270,4 +233,12 @@ export interface DefaultThemeLocaleData extends LocaleData {
270
233
  * A11y text for sidebar toggle button
271
234
  */
272
235
  toggleSidebar?: string;
236
+ /**
237
+ * text for prev link
238
+ */
239
+ prev?: string | false;
240
+ /**
241
+ * text for next link
242
+ */
243
+ next?: string | false;
273
244
  }
@@ -1,12 +1,15 @@
1
1
  import type { GitPluginPageData } from '@vuepress/plugin-git';
2
- import type { NavLink, SidebarConfig } from './nav.js';
3
- export interface DefaultThemePageData extends GitPluginPageData {
2
+ import type { PageFrontmatter } from 'vuepress/shared';
3
+ import type { AutoLinkOptions } from './nav.js';
4
+ import type { SidebarArrayOptions } from './sidebar.js';
5
+ export interface DefaultThemePageData extends Partial<GitPluginPageData> {
4
6
  filePathRelative: string | null;
5
7
  }
6
- export interface DefaultThemePageFrontmatter {
8
+ export interface DefaultThemePageFrontmatter extends PageFrontmatter {
7
9
  home?: boolean;
8
10
  navbar?: boolean;
9
11
  pageClass?: string;
12
+ externalLinkIcon?: boolean;
10
13
  }
11
14
  export interface DefaultThemeHomePageFrontmatter extends DefaultThemePageFrontmatter {
12
15
  home: true;
@@ -34,8 +37,8 @@ export interface DefaultThemeNormalPageFrontmatter extends DefaultThemePageFront
34
37
  editLinkPattern?: string;
35
38
  lastUpdated?: boolean;
36
39
  contributors?: boolean;
37
- sidebar?: 'auto' | false | SidebarConfig;
40
+ sidebar?: SidebarArrayOptions | 'heading' | false;
38
41
  sidebarDepth?: number;
39
- prev?: string | NavLink;
40
- next?: string | NavLink;
42
+ prev?: AutoLinkOptions | string;
43
+ next?: AutoLinkOptions | string;
41
44
  }
@@ -0,0 +1,26 @@
1
+ import type { AutoLinkOptions, NavItemOptions } from './nav.js';
2
+ export type SidebarLinkOptions = AutoLinkOptions;
3
+ export interface SidebarGroupOptions extends NavItemOptions {
4
+ /**
5
+ * Link prefix of current group
6
+ */
7
+ prefix?: string;
8
+ /**
9
+ * Link of current group
10
+ */
11
+ link?: string;
12
+ /**
13
+ * Whether current group is collapsible
14
+ *
15
+ * @default false
16
+ */
17
+ collapsible?: boolean;
18
+ /**
19
+ * Children of current group
20
+ */
21
+ children: SidebarItemOptions[];
22
+ }
23
+ export type SidebarItemOptions = SidebarGroupOptions | SidebarLinkOptions | string;
24
+ export type SidebarArrayOptions = SidebarItemOptions[];
25
+ export type SidebarObjectOptions = Record<string, SidebarArrayOptions | 'heading' | false>;
26
+ export type SidebarOptions = SidebarArrayOptions | SidebarObjectOptions | 'heading';
@@ -0,0 +1 @@
1
+ export {};