@vuepress/theme-default 2.0.0-rc.1 → 2.0.0-rc.11

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.
@@ -41,8 +41,8 @@ const linkTarget = computed(() => {
41
41
  })
42
42
  // if the `target` attr is '_blank'
43
43
  const isBlankTarget = computed(() => linkTarget.value === '_blank')
44
- // is `<RouterLink>` or not
45
- const isRouterLink = computed(
44
+ // is `<RouteLink>` or not
45
+ const isRouteLink = computed(
46
46
  () =>
47
47
  !hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value,
48
48
  )
@@ -74,7 +74,7 @@ const isActiveInSubpath = computed(() => {
74
74
 
75
75
  // if this link is active
76
76
  const isActive = computed(() => {
77
- if (!isRouterLink.value) {
77
+ if (!isRouteLink.value) {
78
78
  return false
79
79
  }
80
80
  if (item.value.activeMatch) {
@@ -85,9 +85,9 @@ const isActive = computed(() => {
85
85
  </script>
86
86
 
87
87
  <template>
88
- <RouterLink
89
- v-if="isRouterLink"
90
- :class="{ 'router-link-active': isActive }"
88
+ <RouteLink
89
+ v-if="isRouteLink"
90
+ :active="isActive"
91
91
  :to="item.link"
92
92
  :aria-label="linkAriaLabel"
93
93
  v-bind="$attrs"
@@ -95,7 +95,7 @@ const isActive = computed(() => {
95
95
  <slot name="before" />
96
96
  {{ item.text }}
97
97
  <slot name="after" />
98
- </RouterLink>
98
+ </RouteLink>
99
99
  <a
100
100
  v-else
101
101
  class="external-link"
@@ -3,6 +3,7 @@ import { computed, h } from 'vue'
3
3
  import type { FunctionalComponent } from 'vue'
4
4
  import {
5
5
  ClientOnly,
6
+ RouteLink,
6
7
  useRouteLocale,
7
8
  useSiteLocaleData,
8
9
  withBase,
@@ -24,12 +25,20 @@ const navbarBrandLogo = computed(() => {
24
25
  }
25
26
  return themeLocale.value.logo
26
27
  })
28
+ const navbarBrandLogoAlt = computed(
29
+ () => themeLocale.value.logoAlt ?? navbarBrandTitle.value,
30
+ )
31
+ const navBarLogoAltMatchesTitle = computed(
32
+ () =>
33
+ navbarBrandTitle.value.toLocaleUpperCase().trim() ===
34
+ navbarBrandLogoAlt.value.toLocaleUpperCase().trim(),
35
+ )
27
36
  const NavbarBrandLogo: FunctionalComponent = () => {
28
37
  if (!navbarBrandLogo.value) return null
29
38
  const img = h('img', {
30
39
  class: 'logo',
31
40
  src: withBase(navbarBrandLogo.value),
32
- alt: '',
41
+ alt: navbarBrandLogoAlt.value,
33
42
  })
34
43
  if (themeLocale.value.logoDark === undefined) {
35
44
  return img
@@ -41,15 +50,16 @@ const NavbarBrandLogo: FunctionalComponent = () => {
41
50
  </script>
42
51
 
43
52
  <template>
44
- <RouterLink :to="navbarBrandLink">
53
+ <RouteLink :to="navbarBrandLink">
45
54
  <NavbarBrandLogo />
46
55
 
47
56
  <span
48
57
  v-if="navbarBrandTitle"
49
58
  class="site-name"
50
59
  :class="{ 'can-hide': navbarBrandLogo }"
60
+ :aria-hidden="navBarLogoAltMatchesTitle"
51
61
  >
52
62
  {{ navbarBrandTitle }}
53
63
  </span>
54
- </RouterLink>
64
+ </RouteLink>
55
65
  </template>
@@ -1,10 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import AutoLink from '@theme/AutoLink.vue'
3
3
  import NavbarDropdown from '@theme/NavbarDropdown.vue'
4
+ import { useRoutePaths } from '@vuepress/helper/client'
4
5
  import { computed, ref } from 'vue'
5
6
  import type { ComputedRef } from 'vue'
6
- import { useRouter } from 'vue-router'
7
- import type { Router } from 'vue-router'
7
+ import { useRoute } from 'vue-router'
8
8
  import { useRouteLocale, useSiteData, useSiteLocaleData } from 'vuepress/client'
9
9
  import { isLinkHttp, isString } from 'vuepress/shared'
10
10
  import type {
@@ -24,7 +24,8 @@ import { getNavLink, resolveRepoType } from '../utils/index.js'
24
24
  * Get navbar config of select language dropdown
25
25
  */
26
26
  const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
27
- const router = useRouter()
27
+ const route = useRoute()
28
+ const routePaths = useRoutePaths()
28
29
  const routeLocale = useRouteLocale()
29
30
  const site = useSiteData()
30
31
  const siteLocale = useSiteLocaleData()
@@ -37,8 +38,8 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
37
38
  if (localePaths.length < 2) {
38
39
  return []
39
40
  }
40
- const currentPath = router.currentRoute.value.path
41
- const currentFullPath = router.currentRoute.value.fullPath
41
+ const currentPath = route.path
42
+ const currentFullPath = route.fullPath
42
43
 
43
44
  const languageDropdown: ResolvedNavbarItem = {
44
45
  text: `${themeLocale.value.selectLanguageText}`,
@@ -67,9 +68,7 @@ const useNavbarSelectLanguage = (): ComputedRef<ResolvedNavbarItem[]> => {
67
68
  routeLocale.value,
68
69
  targetLocalePath,
69
70
  )
70
- if (
71
- router.getRoutes().some((item) => item.path === targetLocalePage)
72
- ) {
71
+ if (routePaths.value.some((item) => item === targetLocalePage)) {
73
72
  // try to keep current hash and params across languages
74
73
  link = currentFullPath.replace(currentPath, targetLocalePage)
75
74
  } else {
@@ -129,17 +128,16 @@ const useNavbarRepo = (): ComputedRef<ResolvedNavbarItem[]> => {
129
128
  }
130
129
 
131
130
  const resolveNavbarItem = (
132
- router: Router,
133
131
  item: NavbarItem | NavbarGroup | string,
134
132
  ): ResolvedNavbarItem => {
135
133
  if (isString(item)) {
136
- return getNavLink(router, item)
134
+ return getNavLink(item)
137
135
  }
138
136
  if ((item as NavbarGroup).children) {
139
137
  return {
140
138
  ...item,
141
139
  children: (item as NavbarGroup).children.map((item) =>
142
- resolveNavbarItem(router, item),
140
+ resolveNavbarItem(item),
143
141
  ),
144
142
  }
145
143
  }
@@ -147,13 +145,10 @@ const resolveNavbarItem = (
147
145
  }
148
146
 
149
147
  const useNavbarConfig = (): ComputedRef<ResolvedNavbarItem[]> => {
150
- const router = useRouter()
151
148
  const themeLocale = useThemeLocaleData()
152
149
 
153
150
  return computed(() =>
154
- (themeLocale.value.navbar || []).map((item) =>
155
- resolveNavbarItem(router, item),
156
- ),
151
+ (themeLocale.value.navbar || []).map((item) => resolveNavbarItem(item)),
157
152
  )
158
153
  }
159
154
 
@@ -178,13 +173,18 @@ useUpdateDeviceStatus(
178
173
  }
179
174
  },
180
175
  )
176
+
177
+ const navbarLabel = computed(() => {
178
+ const themeLocale = useThemeLocaleData()
179
+ return themeLocale.value.navbarLabel ?? 'site navigation'
180
+ })
181
181
  </script>
182
182
 
183
183
  <template>
184
- <nav v-if="navbarLinks.length" class="navbar-items">
184
+ <nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
185
185
  <div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
186
186
  <NavbarDropdown
187
- v-if="item.children"
187
+ v-if="'children' in item"
188
188
  :item="item"
189
189
  :class="isMobile ? 'mobile' : ''"
190
190
  />
@@ -10,7 +10,7 @@ import type {
10
10
  NavLink,
11
11
  ResolvedSidebarItem,
12
12
  } from '../../shared/index.js'
13
- import { useSidebarItems } from '../composables/index.js'
13
+ import { useSidebarItems, useThemeLocaleData } from '../composables/index.js'
14
14
  import { getNavLink } from '../utils/index.js'
15
15
 
16
16
  /**
@@ -96,10 +96,19 @@ const nextNavLink = computed(() => {
96
96
 
97
97
  return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
98
98
  })
99
+
100
+ const navbarLabel = computed(() => {
101
+ const themeLocale = useThemeLocaleData()
102
+ return themeLocale.value.pageNavbarLabel ?? 'page navigation'
103
+ })
99
104
  </script>
100
105
 
101
106
  <template>
102
- <nav v-if="prevNavLink || nextNavLink" class="page-nav">
107
+ <nav
108
+ v-if="prevNavLink || nextNavLink"
109
+ class="page-nav"
110
+ :aria-label="navbarLabel"
111
+ >
103
112
  <p class="inner">
104
113
  <span v-if="prevNavLink" class="prev">
105
114
  <AutoLink :item="prevNavLink" />
@@ -1,5 +1,4 @@
1
1
  import type { ComputedRef, InjectionKey } from 'vue';
2
- import type { Router } from 'vue-router';
3
2
  import type { PageData, PageHeader } from 'vuepress/client';
4
3
  import type { DefaultThemeData, DefaultThemeNormalPageFrontmatter, ResolvedSidebarItem, SidebarConfigArray, SidebarConfigObject } from '../../shared/index.js';
5
4
  export type SidebarItemsRef = ComputedRef<ResolvedSidebarItem[]>;
@@ -17,7 +16,7 @@ export declare const setupSidebarItems: () => void;
17
16
  *
18
17
  * It should only be resolved and provided once
19
18
  */
20
- export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData, router: Router, path: string) => ResolvedSidebarItem[];
19
+ export declare const resolveSidebarItems: (frontmatter: DefaultThemeNormalPageFrontmatter, themeLocale: DefaultThemeData, page: PageData, path: string) => ResolvedSidebarItem[];
21
20
  /**
22
21
  * Util to transform page header to sidebar item
23
22
  */
@@ -30,8 +29,8 @@ export declare const resolveAutoSidebarItems: (page: PageData, sidebarDepth: num
30
29
  /**
31
30
  * Resolve sidebar items if the config is an array
32
31
  */
33
- export declare const resolveArraySidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
32
+ export declare const resolveArraySidebarItems: (page: PageData, path: string, sidebarConfig: SidebarConfigArray, sidebarDepth: number) => ResolvedSidebarItem[];
34
33
  /**
35
34
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
36
35
  */
37
- export declare const resolveMultiSidebarItems: (page: PageData, router: Router, path: string, sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
36
+ export declare const resolveMultiSidebarItems: (page: PageData, path: string, sidebarConfig: SidebarConfigObject, sidebarDepth: number) => ResolvedSidebarItem[];
@@ -1,5 +1,5 @@
1
1
  import { computed, inject, provide } from 'vue';
2
- import { useRoute, useRouter } from 'vue-router';
2
+ import { useRoute } from 'vue-router';
3
3
  import { usePageData, usePageFrontmatter } from 'vuepress/client';
4
4
  import { isPlainObject, isString, resolveLocalePath } from 'vuepress/shared';
5
5
  import { getNavLink } from '../utils/index.js';
@@ -23,8 +23,7 @@ export const setupSidebarItems = () => {
23
23
  const frontmatter = usePageFrontmatter();
24
24
  const page = usePageData();
25
25
  const route = useRoute();
26
- const router = useRouter();
27
- const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, router, route.path));
26
+ const sidebarItems = computed(() => resolveSidebarItems(frontmatter.value, themeLocale.value, page.value, route.path));
28
27
  provide(sidebarItemsSymbol, sidebarItems);
29
28
  };
30
29
  /**
@@ -32,7 +31,7 @@ export const setupSidebarItems = () => {
32
31
  *
33
32
  * It should only be resolved and provided once
34
33
  */
35
- export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path) => {
34
+ export const resolveSidebarItems = (frontmatter, themeLocale, page, path) => {
36
35
  // get sidebar config from frontmatter > theme data
37
36
  const sidebarConfig = frontmatter.sidebar ?? themeLocale.sidebar ?? 'auto';
38
37
  const sidebarDepth = frontmatter.sidebarDepth ?? themeLocale.sidebarDepth ?? 2;
@@ -44,10 +43,10 @@ export const resolveSidebarItems = (frontmatter, themeLocale, page, router, path
44
43
  return resolveAutoSidebarItems(page, sidebarDepth);
45
44
  }
46
45
  if (Array.isArray(sidebarConfig)) {
47
- return resolveArraySidebarItems(page, router, path, sidebarConfig, sidebarDepth);
46
+ return resolveArraySidebarItems(page, path, sidebarConfig, sidebarDepth);
48
47
  }
49
48
  if (isPlainObject(sidebarConfig)) {
50
- return resolveMultiSidebarItems(page, router, path, sidebarConfig, sidebarDepth);
49
+ return resolveMultiSidebarItems(page, path, sidebarConfig, sidebarDepth);
51
50
  }
52
51
  return [];
53
52
  };
@@ -76,11 +75,11 @@ export const resolveAutoSidebarItems = (page, sidebarDepth) => {
76
75
  /**
77
76
  * Resolve sidebar items if the config is an array
78
77
  */
79
- export const resolveArraySidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
78
+ export const resolveArraySidebarItems = (page, path, sidebarConfig, sidebarDepth) => {
80
79
  const handleChildItem = (item) => {
81
80
  let childItem;
82
81
  if (isString(item)) {
83
- childItem = getNavLink(router, item);
82
+ childItem = getNavLink(item);
84
83
  }
85
84
  else {
86
85
  childItem = item;
@@ -108,8 +107,11 @@ export const resolveArraySidebarItems = (page, router, path, sidebarConfig, side
108
107
  /**
109
108
  * Resolve sidebar items if the config is a key -> value (path-prefix -> array) object
110
109
  */
111
- export const resolveMultiSidebarItems = (page, router, path, sidebarConfig, sidebarDepth) => {
110
+ export const resolveMultiSidebarItems = (page, path, sidebarConfig, sidebarDepth) => {
112
111
  const sidebarPath = resolveLocalePath(sidebarConfig, path);
113
112
  const matchedSidebarConfig = sidebarConfig[sidebarPath] ?? [];
114
- return resolveArraySidebarItems(page, router, path, matchedSidebarConfig, sidebarDepth);
113
+ if (matchedSidebarConfig === 'heading') {
114
+ return resolveAutoSidebarItems(page, sidebarDepth);
115
+ }
116
+ return resolveArraySidebarItems(page, path, matchedSidebarConfig, sidebarDepth);
115
117
  };
@@ -1,3 +1,4 @@
1
+ import { hasGlobalComponent } from '@vuepress/helper/client';
1
2
  import { h } from 'vue';
2
3
  import { defineClientConfig } from 'vuepress/client';
3
4
  import { Badge, CodeGroup, CodeGroupItem } from './components/global/index.js';
@@ -7,9 +8,12 @@ import NotFound from './layouts/NotFound.vue';
7
8
  import './styles/index.scss';
8
9
  export default defineClientConfig({
9
10
  enhance({ app, router }) {
10
- app.component('Badge', Badge);
11
- app.component('CodeGroup', CodeGroup);
12
- app.component('CodeGroupItem', CodeGroupItem);
11
+ if (!hasGlobalComponent('Badge'))
12
+ app.component('Badge', Badge);
13
+ if (!hasGlobalComponent('CodeGroup'))
14
+ app.component('CodeGroup', CodeGroup);
15
+ if (!hasGlobalComponent('CodeGroupItem'))
16
+ app.component('CodeGroupItem', CodeGroupItem);
13
17
  // compat with @vuepress/plugin-external-link-icon
14
18
  app.component('AutoLinkExternalIcon', () => {
15
19
  const ExternalLinkIcon = app.component('ExternalLinkIcon');
@@ -1,3 +1,3 @@
1
- export * from '../shared/index.js';
2
1
  export * from './composables/index.js';
3
2
  export * from './utils/index.js';
3
+ export type * from '../shared/index.js';
@@ -1,3 +1,2 @@
1
- export * from '../shared/index.js';
2
1
  export * from './composables/index.js';
3
2
  export * from './utils/index.js';
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { useRouteLocale } from 'vuepress/client'
2
+ import { RouteLink, useRouteLocale } from 'vuepress/client'
3
3
  import { useThemeLocaleData } from '../composables/index.js'
4
4
 
5
5
  const routeLocale = useRouteLocale()
@@ -20,7 +20,7 @@ const homeText = themeLocale.value.backToHome ?? 'Back to home'
20
20
 
21
21
  <blockquote>{{ getMsg() }}</blockquote>
22
22
 
23
- <RouterLink :to="homeLink">{{ homeText }}</RouterLink>
23
+ <RouteLink :to="homeLink">{{ homeText }}</RouteLink>
24
24
  </div>
25
25
  </main>
26
26
  </div>
@@ -97,7 +97,8 @@ h6 {
97
97
  text-decoration: none;
98
98
  position: relative;
99
99
 
100
- &:hover ::before {
100
+ &:hover::before {
101
+ font-size: 0.8em;
101
102
  content: '¶';
102
103
  position: absolute;
103
104
  left: -0.75em;
@@ -94,9 +94,19 @@
94
94
  }
95
95
 
96
96
  // plugin-back-to-top
97
- .back-to-top {
97
+ .vp-back-to-top-button {
98
98
  --back-to-top-color: var(--c-brand);
99
99
  --back-to-top-color-hover: var(--c-brand-light);
100
+ --back-to-top-bg-color: var(--c-bg);
101
+ }
102
+
103
+ // catalog
104
+ .vp-catalog-wrapper {
105
+ --catalog-bg-color: var(--c-bg);
106
+ --catalog-bg-secondary-color: var(--c-bg-dark);
107
+ --catalog-border-color: var(--c-border);
108
+ --catalog-active-color: var(--c-brand);
109
+ --catalog-hover-color: var(--c-brand-light);
100
110
  }
101
111
 
102
112
  // plugin-docsearch
@@ -143,6 +153,17 @@
143
153
  --pwa-popup-btn-hover-bg-color: var(--c-brand-light);
144
154
  }
145
155
 
156
+ // plugin-redirect
157
+ .language-modal-mask {
158
+ --redirect-bg-color: var(--c-bg);
159
+ --redirect-bg-color-light: var(--c-bg-light);
160
+ --redirect-bg-color-lighter: var(--c-bg-lighter);
161
+ --redirect-text-color: var(--c-text);
162
+ --redirect-primary-bg-color: var(--c-brand);
163
+ --redirect-primary-hover-bg-color: var(--c-brand-light);
164
+ --redirect-primary-text-color: var(--c-bg);
165
+ }
166
+
146
167
  // plugin-search
147
168
  .search-box {
148
169
  --search-bg-color: var(--c-bg);
@@ -1,10 +1,4 @@
1
- import type { Router } from 'vue-router';
2
1
  import type { NavLink } from '../../shared/index.js';
3
- declare module 'vue-router' {
4
- interface RouteMeta {
5
- title?: string;
6
- }
7
- }
8
2
  /**
9
3
  * Resolve NavLink props from string
10
4
  *
@@ -12,4 +6,4 @@ declare module 'vue-router' {
12
6
  * - Input: '/README.md'
13
7
  * - Output: { text: 'Home', link: '/' }
14
8
  */
15
- export declare const getNavLink: (router: Router, item: string) => NavLink;
9
+ export declare const getNavLink: (config: string) => NavLink;
@@ -1,4 +1,4 @@
1
- import { getResolveRouteWithRedirect } from './getResolveRouteWithRedirect.js';
1
+ import { resolveRoute } from 'vuepress/client';
2
2
  /**
3
3
  * Resolve NavLink props from string
4
4
  *
@@ -6,13 +6,12 @@ import { getResolveRouteWithRedirect } from './getResolveRouteWithRedirect.js';
6
6
  * - Input: '/README.md'
7
7
  * - Output: { text: 'Home', link: '/' }
8
8
  */
9
- export const getNavLink = (router, item) => {
10
- // the route path of vue-router is url-encoded, and we expect users are using
11
- // non-url-encoded string in theme config, so we need to url-encode it first to
12
- // resolve the route correctly
13
- const resolved = getResolveRouteWithRedirect(router, encodeURI(item));
14
- return {
15
- text: resolved.meta.title || item,
16
- link: resolved.name === '404' ? item : resolved.fullPath,
17
- };
9
+ export const getNavLink = (config) => {
10
+ const { notFound, meta, path } = resolveRoute(config);
11
+ return notFound
12
+ ? { text: path, link: path }
13
+ : {
14
+ text: meta.title || path,
15
+ link: path,
16
+ };
18
17
  };
@@ -1,5 +1,4 @@
1
1
  export * from './getNavLink.js';
2
- export * from './getResolveRouteWithRedirect.js';
3
2
  export * from './isActiveSidebarItem.js';
4
3
  export * from './resolveEditLink.js';
5
4
  export * from './resolveRepoType.js';
@@ -1,5 +1,4 @@
1
1
  export * from './getNavLink.js';
2
- export * from './getResolveRouteWithRedirect.js';
3
2
  export * from './isActiveSidebarItem.js';
4
3
  export * from './resolveEditLink.js';
5
4
  export * from './resolveRepoType.js';
@@ -1,10 +1,14 @@
1
1
  import type { Theme } from 'vuepress/core';
2
2
  import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared/index.js';
3
3
  export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
4
+ /**
5
+ * deployed hostname
6
+ */
7
+ hostname?: string;
4
8
  /**
5
9
  * To avoid confusion with the root `plugins` option,
6
10
  * we use `themePlugins`
7
11
  */
8
12
  themePlugins?: DefaultThemePluginsOptions;
9
13
  }
10
- export declare const defaultTheme: ({ themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
14
+ export declare const defaultTheme: ({ hostname, themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
@@ -1,17 +1,21 @@
1
1
  import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links';
2
2
  import { backToTopPlugin } from '@vuepress/plugin-back-to-top';
3
3
  import { containerPlugin } from '@vuepress/plugin-container';
4
+ import { copyCodePlugin } from '@vuepress/plugin-copy-code';
4
5
  import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon';
5
6
  import { gitPlugin } from '@vuepress/plugin-git';
6
7
  import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom';
7
8
  import { nprogressPlugin } from '@vuepress/plugin-nprogress';
8
9
  import { palettePlugin } from '@vuepress/plugin-palette';
9
10
  import { prismjsPlugin } from '@vuepress/plugin-prismjs';
11
+ import { seoPlugin } from '@vuepress/plugin-seo';
12
+ import { sitemapPlugin } from '@vuepress/plugin-sitemap';
10
13
  import { themeDataPlugin } from '@vuepress/plugin-theme-data';
14
+ import { isPlainObject } from 'vuepress/shared';
11
15
  import { fs, getDirname, path } from 'vuepress/utils';
12
16
  import { assignDefaultLocaleOptions, resolveContainerPluginOptions, } from './utils/index.js';
13
17
  const __dirname = getDirname(import.meta.url);
14
- export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
18
+ export const defaultTheme = ({ hostname, themePlugins = {}, ...localeOptions } = {}) => {
15
19
  assignDefaultLocaleOptions(localeOptions);
16
20
  return {
17
21
  name: '@vuepress/theme-default',
@@ -44,7 +48,17 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
44
48
  })
45
49
  : [],
46
50
  // @vuepress/plugin-back-to-top
47
- themePlugins.backToTop !== false ? backToTopPlugin() : [],
51
+ themePlugins.backToTop !== false
52
+ ? backToTopPlugin(isPlainObject(themePlugins.backToTop) ? themePlugins.backToTop : {})
53
+ : [],
54
+ // @vuepress/plugin-copy-code
55
+ themePlugins.copyCode !== false
56
+ ? copyCodePlugin({
57
+ ...(isPlainObject(themePlugins.copyCode)
58
+ ? themePlugins.copyCode
59
+ : {}),
60
+ })
61
+ : [],
48
62
  // @vuepress/plugin-container
49
63
  themePlugins.container?.tip !== false
50
64
  ? containerPlugin(resolveContainerPluginOptions(localeOptions, 'tip'))
@@ -110,6 +124,22 @@ export const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
110
124
  palettePlugin({ preset: 'sass' }),
111
125
  // @vuepress/plugin-prismjs
112
126
  themePlugins.prismjs !== false ? prismjsPlugin() : [],
127
+ // @vuepress/plugin-seo
128
+ hostname && themePlugins.seo !== false
129
+ ? seoPlugin({
130
+ hostname,
131
+ ...(isPlainObject(themePlugins.seo) ? themePlugins.seo : {}),
132
+ })
133
+ : [],
134
+ // @vuepress/plugin-sitemap
135
+ hostname && themePlugins.sitemap !== false
136
+ ? sitemapPlugin({
137
+ hostname,
138
+ ...(isPlainObject(themePlugins.sitemap)
139
+ ? themePlugins.sitemap
140
+ : {}),
141
+ })
142
+ : [],
113
143
  // @vuepress/plugin-theme-data
114
144
  themeDataPlugin({ themeData: localeOptions }),
115
145
  ],
@@ -1,5 +1,6 @@
1
1
  import { defaultTheme } from './defaultTheme.js';
2
- export * from '../shared/index.js';
3
2
  export * from './defaultTheme.js';
4
3
  export * from './utils/index.js';
4
+ export type * from '../shared/index.js';
5
+ /** @deprecated Use named export instead */
5
6
  export default defaultTheme;
package/lib/node/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defaultTheme } from './defaultTheme.js';
2
- export * from '../shared/index.js';
3
2
  export * from './defaultTheme.js';
4
3
  export * from './utils/index.js';
4
+ /** @deprecated Use named export instead */
5
5
  export default defaultTheme;
@@ -35,7 +35,8 @@ export type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | s
35
35
  collapsible?: boolean;
36
36
  };
37
37
  export type SidebarConfigArray = (SidebarItem | SidebarGroup | string)[];
38
- export type SidebarConfigObject = Record<string, SidebarConfigArray>;
38
+ export type SidebarConfigObjectItem = SidebarConfigArray | 'heading';
39
+ export type SidebarConfigObject = Record<string, SidebarConfigObjectItem>;
39
40
  export type SidebarConfig = SidebarConfigArray | SidebarConfigObject;
40
41
  export type ResolvedSidebarItem = SidebarItem & Partial<NavGroup<ResolvedSidebarItem>> & {
41
42
  collapsible?: boolean;
@@ -1,3 +1,7 @@
1
+ import type { BackToTopPluginOptions } from '@vuepress/plugin-back-to-top';
2
+ import type { CopyCodePluginOptions } from '@vuepress/plugin-copy-code';
3
+ import type { SeoPluginOptions } from '@vuepress/plugin-seo';
4
+ import type { SitemapPluginOptions } from '@vuepress/plugin-sitemap';
1
5
  import type { ThemeData } from '@vuepress/plugin-theme-data';
2
6
  import type { LocaleData } from 'vuepress/shared';
3
7
  import type { NavbarConfig, SidebarConfig } from './nav.js';
@@ -9,7 +13,7 @@ export interface DefaultThemePluginsOptions {
9
13
  /**
10
14
  * Enable @vuepress/plugin-back-to-top or not
11
15
  */
12
- backToTop?: boolean;
16
+ backToTop?: BackToTopPluginOptions | boolean;
13
17
  /**
14
18
  * Enable @vuepress/plugin-container or not
15
19
  */
@@ -21,6 +25,10 @@ export interface DefaultThemePluginsOptions {
21
25
  codeGroup?: boolean;
22
26
  codeGroupItem?: boolean;
23
27
  };
28
+ /**
29
+ * Enable @vuepress/plugin-copy-code or not
30
+ */
31
+ copyCode?: CopyCodePluginOptions | boolean;
24
32
  /**
25
33
  * Enable @vuepress/plugin-external-link-icon or not
26
34
  */
@@ -41,6 +49,14 @@ export interface DefaultThemePluginsOptions {
41
49
  * Enable @vuepress/plugin-prismjs or not
42
50
  */
43
51
  prismjs?: boolean;
52
+ /**
53
+ * Enable @vuepress/plugin-seo or not
54
+ */
55
+ seo?: Partial<SeoPluginOptions> | boolean;
56
+ /**
57
+ * Enable @vuepress/plugin-sitemap or not
58
+ */
59
+ sitemap?: Partial<SitemapPluginOptions> | boolean;
44
60
  }
45
61
  export type DefaultThemeLocaleOptions = DefaultThemeData;
46
62
  export type DefaultThemeData = ThemeData<DefaultThemeLocaleData>;
@@ -69,6 +85,14 @@ export interface DefaultThemeLocaleData extends LocaleData {
69
85
  * Set to `false` to disable navbar in current locale
70
86
  */
71
87
  navbar?: false | NavbarConfig;
88
+ /**
89
+ * Navbar label used for screen readers using the `aria-label` attribute
90
+ */
91
+ navbarLabel?: null | string;
92
+ /**
93
+ * Page navbar label used for screen readers using the `aria-label` attribute
94
+ */
95
+ pageNavbarLabel?: null | string;
72
96
  /**
73
97
  * Navbar logo config
74
98
  *
@@ -81,6 +105,13 @@ export interface DefaultThemeLocaleData extends LocaleData {
81
105
  * Logo to display in navbar in dark mode
82
106
  */
83
107
  logoDark?: null | string;
108
+ /**
109
+ * The alt text of navbar logo.
110
+ * Defaults to the site title if not specified.
111
+ * If the value is the same as the site title, the site title rendered in the navbar will be
112
+ * hidden from screen readers to avoid duplication.
113
+ */
114
+ logoAlt?: null | string;
84
115
  /**
85
116
  * Navbar repository config
86
117
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.11",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -8,13 +8,14 @@
8
8
  "theme",
9
9
  "default"
10
10
  ],
11
- "homepage": "https://github.com/vuepress",
11
+ "homepage": "https://ecosystem.vuejs.press/themes/default/",
12
12
  "bugs": {
13
13
  "url": "https://github.com/vuepress/ecosystem/issues"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
- "url": "git+https://github.com/vuepress/ecosystem.git"
17
+ "url": "git+https://github.com/vuepress/ecosystem.git",
18
+ "directory": "themes/theme-default"
18
19
  },
19
20
  "license": "MIT",
20
21
  "author": "meteorlxy",
@@ -37,20 +38,24 @@
37
38
  ],
38
39
  "scripts": {
39
40
  "build": "tsc -b tsconfig.build.json",
40
- "clean": "rimraf lib *.tsbuildinfo",
41
+ "clean": "rimraf --glob ./lib ./*.tsbuildinfo",
41
42
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
42
43
  },
43
44
  "dependencies": {
44
- "@vuepress/plugin-active-header-links": "2.0.0-rc.1",
45
- "@vuepress/plugin-back-to-top": "2.0.0-rc.1",
46
- "@vuepress/plugin-container": "2.0.0-rc.1",
47
- "@vuepress/plugin-external-link-icon": "2.0.0-rc.1",
48
- "@vuepress/plugin-git": "2.0.0-rc.1",
49
- "@vuepress/plugin-medium-zoom": "2.0.0-rc.1",
50
- "@vuepress/plugin-nprogress": "2.0.0-rc.1",
51
- "@vuepress/plugin-palette": "2.0.0-rc.1",
52
- "@vuepress/plugin-prismjs": "2.0.0-rc.1",
53
- "@vuepress/plugin-theme-data": "2.0.0-rc.1",
45
+ "@vuepress/helper": "~2.0.0-rc.11",
46
+ "@vuepress/plugin-active-header-links": "2.0.0-rc.11",
47
+ "@vuepress/plugin-back-to-top": "2.0.0-rc.11",
48
+ "@vuepress/plugin-container": "2.0.0-rc.11",
49
+ "@vuepress/plugin-copy-code": "2.0.0-rc.11",
50
+ "@vuepress/plugin-external-link-icon": "2.0.0-rc.11",
51
+ "@vuepress/plugin-git": "2.0.0-rc.11",
52
+ "@vuepress/plugin-medium-zoom": "2.0.0-rc.11",
53
+ "@vuepress/plugin-nprogress": "2.0.0-rc.11",
54
+ "@vuepress/plugin-palette": "2.0.0-rc.11",
55
+ "@vuepress/plugin-prismjs": "2.0.0-rc.11",
56
+ "@vuepress/plugin-seo": "2.0.0-rc.11",
57
+ "@vuepress/plugin-sitemap": "2.0.0-rc.11",
58
+ "@vuepress/plugin-theme-data": "2.0.0-rc.11",
54
59
  "@vueuse/core": "^10.7.2",
55
60
  "sass": "^1.70.0",
56
61
  "vue": "^3.4.15",
@@ -58,7 +63,7 @@
58
63
  },
59
64
  "peerDependencies": {
60
65
  "sass-loader": "^14.0.0",
61
- "vuepress": "2.0.0-rc.2"
66
+ "vuepress": "2.0.0-rc.6"
62
67
  },
63
68
  "peerDependenciesMeta": {
64
69
  "sass-loader": {
@@ -68,5 +73,5 @@
68
73
  "publishConfig": {
69
74
  "access": "public"
70
75
  },
71
- "gitHead": "1de7fea6963c3dd6c89df21eca4accc2d31204a4"
76
+ "gitHead": "7ba11252716b7f900ecb4215b8a523c51d751738"
72
77
  }
@@ -1,9 +1,9 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="{{ lang }}">
3
3
  <head>
4
- <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <meta name="generator" content="VuePress {{ version }}">
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <meta name="generator" content="VuePress {{ version }}" />
7
7
  <style>
8
8
  :root {
9
9
  --c-bg: #fff;
@@ -11,16 +11,19 @@
11
11
  html.dark {
12
12
  --c-bg: #22272e;
13
13
  }
14
- html, body {
14
+ html,
15
+ body {
15
16
  background-color: var(--c-bg);
16
17
  }
17
18
  </style>
18
19
  <script>
19
- const userMode = localStorage.getItem('vuepress-color-scheme');
20
- const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
21
- if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
22
- document.documentElement.classList.toggle('dark', true);
23
- }
20
+ const userMode = localStorage.getItem('vuepress-color-scheme')
21
+ const systemDarkMode =
22
+ window.matchMedia &&
23
+ window.matchMedia('(prefers-color-scheme: dark)').matches
24
+ if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
25
+ document.documentElement.classList.toggle('dark', true)
26
+ }
24
27
  </script>
25
28
  <!--vuepress-ssr-head-->
26
29
  <!--vuepress-ssr-styles-->
@@ -1,5 +0,0 @@
1
- import type { Router } from 'vue-router';
2
- /**
3
- * Resolve a route with redirection
4
- */
5
- export declare const getResolveRouteWithRedirect: (router: Router, to: import("vue-router").RouteLocationRaw, currentLocation?: import("vue-router").RouteLocationNormalizedLoaded | undefined) => ReturnType<Router['resolve']>;
@@ -1,22 +0,0 @@
1
- import { isFunction, isString } from 'vuepress/shared';
2
- /**
3
- * Resolve a route with redirection
4
- */
5
- export const getResolveRouteWithRedirect = (router, ...args) => {
6
- const route = router.resolve(...args);
7
- const lastMatched = route.matched[route.matched.length - 1];
8
- if (!lastMatched?.redirect) {
9
- return route;
10
- }
11
- const { redirect } = lastMatched;
12
- const resolvedRedirect = isFunction(redirect) ? redirect(route) : redirect;
13
- const resolvedRedirectObj = isString(resolvedRedirect)
14
- ? { path: resolvedRedirect }
15
- : resolvedRedirect;
16
- return getResolveRouteWithRedirect(router, {
17
- hash: route.hash,
18
- query: route.query,
19
- params: route.params,
20
- ...resolvedRedirectObj,
21
- });
22
- };