@vuepress/theme-default 2.0.0-beta.27 → 2.0.0-beta.31

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 (48) hide show
  1. package/lib/client/clientAppEnhance.js +4 -5
  2. package/lib/client/components/DropdownLink.vue +51 -51
  3. package/lib/client/components/DropdownTransition.vue +11 -11
  4. package/lib/client/components/Home.vue +12 -107
  5. package/lib/client/components/HomeContent.vue +5 -0
  6. package/lib/client/components/HomeFeatures.vue +23 -0
  7. package/lib/client/components/HomeFooter.vue +17 -0
  8. package/lib/client/components/HomeHero.vue +97 -0
  9. package/lib/client/components/NavLink.vue +33 -33
  10. package/lib/client/components/Navbar.vue +23 -57
  11. package/lib/client/components/NavbarBrand.vue +55 -0
  12. package/lib/client/components/NavbarLinks.vue +16 -11
  13. package/lib/client/components/Page.vue +5 -5
  14. package/lib/client/components/PageMeta.vue +31 -29
  15. package/lib/client/components/PageNav.vue +14 -16
  16. package/lib/client/components/Sidebar.vue +6 -18
  17. package/lib/client/components/SidebarItem.vue +69 -0
  18. package/lib/client/components/SidebarItems.vue +16 -0
  19. package/lib/client/components/ToggleDarkModeButton.vue +11 -11
  20. package/lib/client/components/ToggleSidebarButton.vue +8 -8
  21. package/lib/client/components/global/Badge.vue +12 -12
  22. package/lib/client/components/global/CodeGroupItem.vue +10 -10
  23. package/lib/client/components/global/{OutboundLink.vue → ExternalLinkIcon.vue} +7 -10
  24. package/lib/client/layouts/404.vue +12 -12
  25. package/lib/client/layouts/Layout.vue +54 -54
  26. package/lib/client/styles/{_wrapper.scss → _mixins.scss} +6 -1
  27. package/lib/client/styles/code.scss +2 -1
  28. package/lib/client/styles/dropdown.scss +2 -2
  29. package/lib/client/styles/layout.scss +2 -2
  30. package/lib/client/styles/normalize.scss +5 -0
  31. package/lib/client/styles/page.scss +11 -3
  32. package/lib/client/styles/sidebar.scss +61 -64
  33. package/lib/client/styles/vars.scss +5 -0
  34. package/lib/client/utils/index.d.ts +1 -0
  35. package/lib/client/utils/index.js +1 -0
  36. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  37. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  38. package/lib/client/utils/resolveEditLink.d.ts +1 -1
  39. package/lib/client/utils/resolveEditLink.js +11 -6
  40. package/lib/node/defaultTheme.js +18 -3
  41. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +3 -1
  42. package/lib/node/utils/assignDefaultLocaleOptions.js +5 -5
  43. package/lib/shared/nav.d.ts +9 -3
  44. package/lib/shared/options.d.ts +5 -1
  45. package/lib/shared/page.d.ts +2 -1
  46. package/package.json +20 -19
  47. package/lib/client/components/SidebarChild.d.ts +0 -6
  48. package/lib/client/components/SidebarChild.js +0 -76
@@ -1,5 +1,5 @@
1
+ @import '_mixins';
1
2
  @import '_variables';
2
- @import '_wrapper';
3
3
 
4
4
  .page {
5
5
  padding-bottom: 2rem;
@@ -7,7 +7,7 @@
7
7
  }
8
8
 
9
9
  .page-meta {
10
- @extend %wrapper;
10
+ @include content_wrapper;
11
11
  padding-top: 1rem;
12
12
  padding-bottom: 1rem;
13
13
  overflow: auto;
@@ -51,7 +51,7 @@
51
51
  }
52
52
 
53
53
  .page-nav {
54
- @extend %wrapper;
54
+ @include content_wrapper;
55
55
  padding-top: 1rem;
56
56
  padding-bottom: 0;
57
57
 
@@ -64,7 +64,15 @@
64
64
  overflow: auto;
65
65
  }
66
66
 
67
+ .prev {
68
+ a:before {
69
+ content: '←';
70
+ }
71
+ }
67
72
  .next {
68
73
  float: right;
74
+ a:after {
75
+ content: '→';
76
+ }
69
77
  }
70
78
  }
@@ -1,3 +1,4 @@
1
+ @import '_mixins';
1
2
  @import '_variables';
2
3
 
3
4
  .sidebar {
@@ -29,17 +30,8 @@
29
30
  }
30
31
  }
31
32
 
32
- .sidebar-links {
33
+ .sidebar-items {
33
34
  padding: 1.5rem 0;
34
-
35
- > li:not(:first-child) {
36
- margin-top: 0.75rem;
37
- }
38
-
39
- .sidebar-sub-items {
40
- padding-left: 1rem;
41
- font-size: 0.95em;
42
- }
43
35
  }
44
36
  }
45
37
 
@@ -56,53 +48,74 @@
56
48
  }
57
49
  }
58
50
 
59
- .sidebar-links {
51
+ .sidebar-items {
60
52
  padding: 1rem 0;
61
53
  }
62
54
  }
63
55
  }
64
56
 
65
- .sidebar-heading {
66
- color: var(--c-text);
67
- transition: color 0.15s ease;
68
- font-size: 1.1em;
69
- font-weight: bold;
70
- padding: 0.35rem 1.5rem 0.35rem 1.25rem;
71
- width: 100%;
72
- box-sizing: border-box;
73
- margin: 0;
74
- border-left: 0.25rem solid transparent;
75
-
76
- .arrow {
77
- position: relative;
78
- top: -0.12em;
79
- left: 0.5em;
80
- }
81
- }
57
+ .sidebar-item {
58
+ cursor: default;
82
59
 
83
- .sidebar-item:not(.sidebar-heading) {
84
- font-size: 1em;
85
- font-weight: 400;
86
- display: inline-block;
87
- color: var(--c-text);
88
- border-left: 0.25rem solid transparent;
89
- margin: 0;
90
- padding: 0.35rem 1rem 0.35rem 2rem;
91
- line-height: 1.4;
92
- width: 100%;
93
- box-sizing: border-box;
94
-
95
- .sidebar-links > &:not(:first-child) {
96
- margin-top: 0.75rem;
97
- }
60
+ &.sidebar-heading {
61
+ color: var(--c-text);
62
+ transition: color 0.15s ease;
63
+ font-size: 1.1em;
64
+ font-weight: bold;
65
+ padding: 0.35rem 1.5rem 0.35rem 1.25rem;
66
+ width: 100%;
67
+ box-sizing: border-box;
68
+ margin: 0;
69
+ border-left: 0.25rem solid transparent;
70
+
71
+ &.collapsible {
72
+ cursor: pointer;
73
+
74
+ & + .sidebar-item-children {
75
+ @include dropdown_wrapper;
76
+ margin-bottom: 0.75rem;
77
+ }
78
+ }
98
79
 
99
- .sidebar-sub-items & {
100
- padding: 0.25rem 1rem 0.25rem 1.75rem;
80
+ .arrow {
81
+ position: relative;
82
+ top: -0.12em;
83
+ left: 0.5em;
84
+ }
101
85
  }
102
- }
103
86
 
104
- .sidebar-item {
105
- cursor: default;
87
+ &:not(.sidebar-heading) {
88
+ font-size: 1em;
89
+ font-weight: 400;
90
+ display: inline-block;
91
+ color: var(--c-text);
92
+ border-left: 0.25rem solid transparent;
93
+ margin: 0;
94
+ padding: 0.35rem 1rem 0.35rem 2rem;
95
+ line-height: 1.4;
96
+ width: 100%;
97
+ box-sizing: border-box;
98
+
99
+ &.active {
100
+ font-weight: 600;
101
+ color: var(--c-text-accent);
102
+ border-left-color: var(--c-text-accent);
103
+ }
104
+
105
+ & + .sidebar-item-children {
106
+ padding-left: 1rem;
107
+ font-size: 0.95em;
108
+ }
109
+
110
+ .sidebar-item-children .sidebar-item-children & {
111
+ padding: 0.25rem 1rem 0.25rem 1.75rem;
112
+
113
+ &.active {
114
+ font-weight: 500;
115
+ border-left-color: transparent;
116
+ }
117
+ }
118
+ }
106
119
  }
107
120
 
108
121
  a.sidebar-item {
@@ -111,20 +124,4 @@ a.sidebar-item {
111
124
  &:hover {
112
125
  color: var(--c-text-accent);
113
126
  }
114
-
115
- &.active {
116
- font-weight: 600;
117
- color: var(--c-text-accent);
118
- border-left-color: var(--c-text-accent);
119
- }
120
-
121
- &.sidebar-heading.active {
122
- font-weight: bold;
123
- border-left-color: transparent;
124
- }
125
-
126
- .sidebar-sub-items &.active {
127
- font-weight: 500;
128
- border-left-color: transparent;
129
- }
130
127
  }
@@ -95,6 +95,11 @@
95
95
  --docsearch-footer-background: var(--c-bg);
96
96
  }
97
97
 
98
+ // plugin-external-link-icon
99
+ .external-link-icon {
100
+ --external-link-icon-color: var(--c-text-quote);
101
+ }
102
+
98
103
  // plugin-medium-zoom
99
104
  .medium-zoom-overlay {
100
105
  --medium-zoom-bg-color: var(--c-bg);
@@ -1,2 +1,3 @@
1
+ export * from './isActiveSidebarItem';
1
2
  export * from './resolveEditLink';
2
3
  export * from './resolveRepoType';
@@ -1,2 +1,3 @@
1
+ export * from './isActiveSidebarItem';
1
2
  export * from './resolveEditLink';
2
3
  export * from './resolveRepoType';
@@ -0,0 +1,3 @@
1
+ import type { RouteLocationNormalizedLoaded } from 'vue-router';
2
+ import type { ResolvedSidebarItem } from '../../shared';
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
+ };
@@ -4,6 +4,6 @@ export declare const resolveEditLink: ({ docsRepo, docsBranch, docsDir, filePath
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;
@@ -6,15 +6,20 @@ export const editLinkPatterns = {
6
6
  Gitee: ':repo/edit/:branch/:path',
7
7
  Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
8
8
  };
9
- export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
10
- const repoType = resolveRepoType(docsRepo);
11
- let pattern;
9
+ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
12
10
  if (editLinkPattern) {
13
- pattern = editLinkPattern;
11
+ return editLinkPattern;
14
12
  }
15
- else if (repoType !== null) {
16
- pattern = editLinkPatterns[repoType];
13
+ const repoType = resolveRepoType(docsRepo);
14
+ if (repoType !== null) {
15
+ return editLinkPatterns[repoType];
17
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 });
18
23
  if (!pattern)
19
24
  return null;
20
25
  return pattern
@@ -3,15 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultTheme = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const utils_2 = require("./utils");
6
- const defaultTheme = ({ themePlugins = {}, ...localeOptions }) => {
6
+ const defaultTheme = ({ themePlugins = {}, ...localeOptions }, app) => {
7
+ if (app.options.bundler.endsWith('vite')) {
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
+ app.options.bundlerConfig.viteOptions = require('vite').mergeConfig(app.options.bundlerConfig.viteOptions, {
10
+ css: {
11
+ preprocessorOptions: {
12
+ scss: { charset: false },
13
+ },
14
+ },
15
+ });
16
+ }
7
17
  (0, utils_2.assignDefaultLocaleOptions)(localeOptions);
8
18
  return {
9
19
  name: '@vuepress/theme-default',
10
20
  layouts: utils_1.path.resolve(__dirname, '../client/layouts'),
11
21
  clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
12
22
  clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
13
- // use the relative file path to generate edit link
14
- extendsPageData: ({ filePathRelative }) => ({ filePathRelative }),
23
+ extendsPage: (page) => {
24
+ // save relative file path into page data to generate edit link
25
+ page.data.filePathRelative = page.filePathRelative;
26
+ // save title into route meta to generate navbar and sidebar
27
+ page.routeMeta.title = page.title;
28
+ },
15
29
  plugins: [
16
30
  [
17
31
  '@vuepress/active-header-links',
@@ -42,6 +56,7 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions }) => {
42
56
  '@vuepress/container',
43
57
  (0, utils_2.resolveContainerPluginOptionsForCodeGroupItem)(themePlugins),
44
58
  ],
59
+ ['@vuepress/external-link-icon', themePlugins.externalLinkIcon !== false],
45
60
  ['@vuepress/git', (0, utils_2.resolveGitPluginOptions)(themePlugins, localeOptions)],
46
61
  ['@vuepress/medium-zoom', (0, utils_2.resolveMediumZoomPluginOptions)(themePlugins)],
47
62
  ['@vuepress/nprogress', themePlugins.nprogress !== false],
@@ -1,4 +1,6 @@
1
- import type { DefaultThemeLocaleOptions } from '../../shared';
1
+ import type { DefaultThemeLocaleData, DefaultThemeLocaleOptions } from '../../shared';
2
+ export declare const DEFAULT_LOCALE_OPTIONS: DefaultThemeLocaleOptions;
3
+ export declare const DEFAULT_LOCALE_DATA: DefaultThemeLocaleData;
2
4
  /**
3
5
  * Assign default options to `themeConfig`
4
6
  */
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assignDefaultLocaleOptions = void 0;
4
- const defaultLocaleOptions = {
3
+ exports.assignDefaultLocaleOptions = exports.DEFAULT_LOCALE_DATA = exports.DEFAULT_LOCALE_OPTIONS = void 0;
4
+ exports.DEFAULT_LOCALE_OPTIONS = {
5
5
  // navbar
6
6
  navbar: [],
7
7
  logo: null,
@@ -32,7 +32,7 @@ const defaultLocaleOptions = {
32
32
  toggleDarkMode: 'toggle dark mode',
33
33
  toggleSidebar: 'toggle sidebar',
34
34
  };
35
- const defaultLocaleData = {
35
+ exports.DEFAULT_LOCALE_DATA = {
36
36
  // navbar
37
37
  selectLanguageName: 'English',
38
38
  };
@@ -47,11 +47,11 @@ const assignDefaultLocaleOptions = (localeOptions) => {
47
47
  localeOptions.locales['/'] = {};
48
48
  }
49
49
  Object.assign(localeOptions, {
50
- ...defaultLocaleOptions,
50
+ ...exports.DEFAULT_LOCALE_OPTIONS,
51
51
  ...localeOptions,
52
52
  });
53
53
  Object.assign(localeOptions.locales['/'], {
54
- ...defaultLocaleData,
54
+ ...exports.DEFAULT_LOCALE_DATA,
55
55
  ...localeOptions.locales['/'],
56
56
  });
57
57
  };
@@ -30,8 +30,14 @@ export declare type ResolvedNavbarItem = NavbarItem | NavGroup<ResolvedNavbarIte
30
30
  /**
31
31
  * Sidebar types
32
32
  */
33
- export declare type SidebarItem = NavItem & Partial<NavLink> & Partial<Pick<NavGroup<NavLink | SidebarItem | string>, 'children'>>;
34
- export declare type SidebarConfigArray = (SidebarItem | string)[];
33
+ export declare type SidebarItem = NavItem & Partial<NavLink>;
34
+ export declare type SidebarGroup = SidebarItem & NavGroup<SidebarItem | SidebarGroup | string>;
35
+ export declare type SidebarGroupCollapsible = SidebarGroup & {
36
+ collapsible?: boolean;
37
+ };
38
+ export declare type SidebarConfigArray = (SidebarItem | SidebarGroupCollapsible | string)[];
35
39
  export declare type SidebarConfigObject = Record<string, SidebarConfigArray>;
36
40
  export declare type SidebarConfig = SidebarConfigArray | SidebarConfigObject;
37
- export declare type ResolvedSidebarItem = NavItem & Partial<NavLink> & Partial<Pick<NavGroup<ResolvedSidebarItem>, 'children'>>;
41
+ export declare type ResolvedSidebarItem = SidebarItem & Partial<NavGroup<ResolvedSidebarItem>> & {
42
+ collapsible?: boolean;
43
+ };
@@ -21,6 +21,10 @@ export interface DefaultThemePluginsOptions {
21
21
  codeGroup?: boolean;
22
22
  codeGroupItem?: boolean;
23
23
  };
24
+ /**
25
+ * Enable @vuepress/plugin-external-link-icon or not
26
+ */
27
+ externalLinkIcon?: boolean;
24
28
  /**
25
29
  * Enable @vuepress/plugin-git or not
26
30
  */
@@ -219,7 +223,7 @@ export interface DefaultThemeLocaleData extends LocaleData {
219
223
  */
220
224
  backToHome?: string;
221
225
  /**
222
- * A11y text for `<OutboundLink>`
226
+ * A11y text for external link icon
223
227
  */
224
228
  openInNewWindow?: string;
225
229
  /**
@@ -1,7 +1,7 @@
1
1
  import type { GitPluginPageData } from '@vuepress/plugin-git';
2
2
  import type { NavLink, SidebarConfig } from './nav';
3
3
  export interface DefaultThemePageData extends GitPluginPageData {
4
- filePathRelative: string;
4
+ filePathRelative: string | null;
5
5
  }
6
6
  export interface DefaultThemePageFrontmatter {
7
7
  home?: boolean;
@@ -11,6 +11,7 @@ export interface DefaultThemePageFrontmatter {
11
11
  export interface DefaultThemeHomePageFrontmatter extends DefaultThemePageFrontmatter {
12
12
  home: true;
13
13
  heroImage?: string;
14
+ heroImageDark?: string;
14
15
  heroAlt?: string;
15
16
  heroText?: string | null;
16
17
  tagline?: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.27",
3
+ "version": "2.0.0-beta.31",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -29,27 +29,28 @@
29
29
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
30
30
  },
31
31
  "dependencies": {
32
- "@vuepress/client": "2.0.0-beta.27",
33
- "@vuepress/core": "2.0.0-beta.27",
34
- "@vuepress/plugin-active-header-links": "2.0.0-beta.27",
35
- "@vuepress/plugin-back-to-top": "2.0.0-beta.27",
36
- "@vuepress/plugin-container": "2.0.0-beta.27",
37
- "@vuepress/plugin-git": "2.0.0-beta.27",
38
- "@vuepress/plugin-medium-zoom": "2.0.0-beta.27",
39
- "@vuepress/plugin-nprogress": "2.0.0-beta.27",
40
- "@vuepress/plugin-palette": "2.0.0-beta.27",
41
- "@vuepress/plugin-prismjs": "2.0.0-beta.27",
42
- "@vuepress/plugin-theme-data": "2.0.0-beta.27",
43
- "@vuepress/shared": "2.0.0-beta.27",
44
- "@vuepress/utils": "2.0.0-beta.27",
45
- "@vueuse/core": "^6.7.3",
46
- "sass": "^1.43.4",
47
- "sass-loader": "^12.2.0",
48
- "vue": "^3.2.20",
32
+ "@vuepress/client": "2.0.0-beta.29",
33
+ "@vuepress/core": "2.0.0-beta.29",
34
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.29",
35
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.30",
36
+ "@vuepress/plugin-container": "2.0.0-beta.29",
37
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.29",
38
+ "@vuepress/plugin-git": "2.0.0-beta.29",
39
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.29",
40
+ "@vuepress/plugin-nprogress": "2.0.0-beta.29",
41
+ "@vuepress/plugin-palette": "2.0.0-beta.29",
42
+ "@vuepress/plugin-prismjs": "2.0.0-beta.29",
43
+ "@vuepress/plugin-theme-data": "2.0.0-beta.29",
44
+ "@vuepress/shared": "2.0.0-beta.28",
45
+ "@vuepress/utils": "2.0.0-beta.28",
46
+ "@vueuse/core": "^7.1.2",
47
+ "sass": "^1.44.0",
48
+ "sass-loader": "^12.4.0",
49
+ "vue": "^3.2.24",
49
50
  "vue-router": "^4.0.12"
50
51
  },
51
52
  "publishConfig": {
52
53
  "access": "public"
53
54
  },
54
- "gitHead": "2671a94fe6864e215eb84f318b7e657744a0bc5d"
55
+ "gitHead": "e7c89264b0f0acb20e477ad1eda89e0f70057014"
55
56
  }
@@ -1,6 +0,0 @@
1
- import type { FunctionalComponent } from 'vue';
2
- import type { ResolvedSidebarItem } from '../../shared';
3
- export declare const SidebarChild: FunctionalComponent<{
4
- item: ResolvedSidebarItem;
5
- depth?: number;
6
- }>;
@@ -1,76 +0,0 @@
1
- import { h } from 'vue';
2
- import { useRoute } from 'vue-router';
3
- import NavLink from './NavLink.vue';
4
- const normalizePath = (path) => decodeURI(path)
5
- .replace(/#.*$/, '')
6
- .replace(/(index)?\.(md|html)$/, '');
7
- const isActiveLink = (route, link) => {
8
- if (link === undefined) {
9
- return false;
10
- }
11
- if (route.hash === link) {
12
- return true;
13
- }
14
- const currentPath = normalizePath(route.path);
15
- const targetPath = normalizePath(link);
16
- return currentPath === targetPath;
17
- };
18
- const isActiveItem = (route, item) => {
19
- if (isActiveLink(route, item.link)) {
20
- return true;
21
- }
22
- if (item.children) {
23
- return item.children.some((child) => isActiveItem(route, child));
24
- }
25
- return false;
26
- };
27
- const renderItem = (item, props) => {
28
- // if the item has link, render it as `<NavLink>`
29
- if (item.link) {
30
- return h(NavLink, {
31
- ...props,
32
- item,
33
- });
34
- }
35
- // if the item only has text, render it as `<p>`
36
- return h('p', props, item.text);
37
- };
38
- const renderChildren = (item, depth) => {
39
- var _a;
40
- if (!((_a = item.children) === null || _a === void 0 ? void 0 : _a.length)) {
41
- return null;
42
- }
43
- return h('ul', {
44
- class: {
45
- 'sidebar-sub-items': depth > 0,
46
- },
47
- }, item.children.map((child) => h('li', h(SidebarChild, {
48
- item: child,
49
- depth: depth + 1,
50
- }))));
51
- };
52
- export const SidebarChild = ({ item, depth = 0 }) => {
53
- const route = useRoute();
54
- const active = isActiveItem(route, item);
55
- return [
56
- renderItem(item, {
57
- class: {
58
- 'sidebar-heading': depth === 0,
59
- 'sidebar-item': true,
60
- active,
61
- },
62
- }),
63
- renderChildren(item, depth),
64
- ];
65
- };
66
- SidebarChild.displayName = 'SidebarChild';
67
- SidebarChild.props = {
68
- item: {
69
- type: Object,
70
- required: true,
71
- },
72
- depth: {
73
- type: Number,
74
- required: false,
75
- },
76
- };