@vuepress/theme-default 2.0.0-beta.29 → 2.0.0-beta.33

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 (45) hide show
  1. package/lib/client/components/{NavLink.vue → AutoLink.vue} +28 -29
  2. package/lib/client/components/DropdownTransition.vue +11 -11
  3. package/lib/client/components/Home.vue +12 -110
  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 +97 -0
  8. package/lib/client/components/Navbar.vue +26 -60
  9. package/lib/client/components/NavbarBrand.vue +55 -0
  10. package/lib/client/components/{DropdownLink.vue → NavbarDropdown.vue} +64 -64
  11. package/lib/client/components/{NavbarLinks.vue → NavbarItems.vue} +12 -13
  12. package/lib/client/components/Page.vue +5 -5
  13. package/lib/client/components/PageMeta.vue +33 -34
  14. package/lib/client/components/PageNav.vue +20 -20
  15. package/lib/client/components/Sidebar.vue +7 -19
  16. package/lib/client/components/SidebarItem.vue +74 -0
  17. package/lib/client/components/SidebarItems.vue +16 -0
  18. package/lib/client/components/ToggleDarkModeButton.vue +11 -11
  19. package/lib/client/components/ToggleSidebarButton.vue +8 -8
  20. package/lib/client/components/global/Badge.vue +12 -12
  21. package/lib/client/components/global/CodeGroupItem.vue +10 -10
  22. package/lib/client/components/global/ExternalLinkIcon.vue +6 -6
  23. package/lib/client/index.d.ts +2 -2
  24. package/lib/client/layouts/404.vue +12 -12
  25. package/lib/client/layouts/Layout.vue +58 -58
  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/index.scss +1 -1
  29. package/lib/client/styles/layout.scss +2 -2
  30. package/lib/client/styles/{dropdown.scss → navbar-dropdown.scss} +25 -33
  31. package/lib/client/styles/navbar.scss +8 -8
  32. package/lib/client/styles/normalize.scss +4 -0
  33. package/lib/client/styles/page.scss +5 -5
  34. package/lib/client/styles/sidebar.scss +67 -70
  35. package/lib/client/styles/transitions.scss +11 -2
  36. package/lib/client/utils/index.d.ts +1 -0
  37. package/lib/client/utils/index.js +1 -0
  38. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  39. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  40. package/lib/node/defaultTheme.js +9 -0
  41. package/lib/shared/nav.d.ts +10 -4
  42. package/package.json +21 -20
  43. package/templates/index.build.html +33 -0
  44. package/lib/client/components/SidebarChild.d.ts +0 -6
  45. package/lib/client/components/SidebarChild.js +0 -76
@@ -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
+ };
@@ -18,6 +18,15 @@ const defaultTheme = ({ themePlugins = {}, ...localeOptions }, app) => {
18
18
  return {
19
19
  name: '@vuepress/theme-default',
20
20
  layouts: utils_1.path.resolve(__dirname, '../client/layouts'),
21
+ templateBuild: utils_1.path.resolve(__dirname, '../../templates/index.build.html'),
22
+ // use alias to make all components replaceable
23
+ alias: Object.fromEntries(utils_1.fs
24
+ .readdirSync(utils_1.path.resolve(__dirname, '../client/components'))
25
+ .filter((file) => file.endsWith('.vue'))
26
+ .map((file) => [
27
+ `@theme/${file}`,
28
+ utils_1.path.resolve(__dirname, '../client/components', file),
29
+ ])),
21
30
  clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
22
31
  clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
23
32
  extendsPage: (page) => {
@@ -12,7 +12,7 @@ export interface NavGroup<T> extends NavItem {
12
12
  children: T[];
13
13
  }
14
14
  /**
15
- * Props for `<NavLink>`
15
+ * Props for `<AutoLink>`
16
16
  */
17
17
  export interface NavLink extends NavItem {
18
18
  link: string;
@@ -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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/theme-default",
3
- "version": "2.0.0-beta.29",
3
+ "version": "2.0.0-beta.33",
4
4
  "description": "Default theme of VuePress",
5
5
  "keywords": [
6
6
  "vuepress-theme",
@@ -21,7 +21,8 @@
21
21
  "main": "lib/node/index.js",
22
22
  "types": "lib/node/index.d.ts",
23
23
  "files": [
24
- "lib"
24
+ "lib",
25
+ "templates"
25
26
  ],
26
27
  "scripts": {
27
28
  "build": "tsc -b tsconfig.build.json",
@@ -29,28 +30,28 @@
29
30
  "copy": "cpx \"src/**/*.{d.ts,vue,scss}\" lib"
30
31
  },
31
32
  "dependencies": {
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.29",
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",
33
+ "@vuepress/client": "2.0.0-beta.33",
34
+ "@vuepress/core": "2.0.0-beta.33",
35
+ "@vuepress/plugin-active-header-links": "2.0.0-beta.33",
36
+ "@vuepress/plugin-back-to-top": "2.0.0-beta.33",
37
+ "@vuepress/plugin-container": "2.0.0-beta.33",
38
+ "@vuepress/plugin-external-link-icon": "2.0.0-beta.33",
39
+ "@vuepress/plugin-git": "2.0.0-beta.33",
40
+ "@vuepress/plugin-medium-zoom": "2.0.0-beta.33",
41
+ "@vuepress/plugin-nprogress": "2.0.0-beta.33",
42
+ "@vuepress/plugin-palette": "2.0.0-beta.33",
43
+ "@vuepress/plugin-prismjs": "2.0.0-beta.33",
44
+ "@vuepress/plugin-theme-data": "2.0.0-beta.33",
45
+ "@vuepress/shared": "2.0.0-beta.33",
46
+ "@vuepress/utils": "2.0.0-beta.33",
47
+ "@vueuse/core": "^7.5.3",
48
+ "sass": "^1.47.0",
48
49
  "sass-loader": "^12.4.0",
49
- "vue": "^3.2.24",
50
+ "vue": "^3.2.26",
50
51
  "vue-router": "^4.0.12"
51
52
  },
52
53
  "publishConfig": {
53
54
  "access": "public"
54
55
  },
55
- "gitHead": "2c6eb4270f96b6351cd1f565798bed1f662a6bb2"
56
+ "gitHead": "0934a5d6685922e0dc6391622b00a3b89140492c"
56
57
  }
@@ -0,0 +1,33 @@
1
+ <!DOCTYPE html>
2
+ <html lang="{{ lang }}">
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 }}">
7
+ <style>
8
+ :root {
9
+ --c-bg: #fff;
10
+ }
11
+ html.dark {
12
+ --c-bg: #22272e;
13
+ }
14
+ html, body {
15
+ background-color: var(--c-bg);
16
+ }
17
+ </style>
18
+ <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
+ }
24
+ </script>
25
+ <!--vuepress-ssr-head-->
26
+ <!--vuepress-ssr-resources-->
27
+ <!--vuepress-ssr-styles-->
28
+ </head>
29
+ <body>
30
+ <div id="app"><!--vuepress-ssr-app--></div>
31
+ <!--vuepress-ssr-scripts-->
32
+ </body>
33
+ </html>
@@ -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
- };