@vuepress/theme-default 2.0.0-beta.4 → 2.0.0-beta.40

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 (132) hide show
  1. package/lib/{clientAppEnhance.d.ts → client/clientAppEnhance.d.ts} +0 -0
  2. package/lib/client/clientAppEnhance.js +34 -0
  3. package/lib/{clientAppSetup.d.ts → client/clientAppSetup.d.ts} +0 -0
  4. package/lib/client/clientAppSetup.js +6 -0
  5. package/lib/client/components/AutoLink.vue +113 -0
  6. package/lib/client/components/DropdownTransition.vue +21 -0
  7. package/lib/client/components/Home.vue +15 -0
  8. package/lib/client/components/HomeContent.vue +5 -0
  9. package/lib/client/components/HomeFeatures.vue +23 -0
  10. package/lib/client/components/HomeFooter.vue +17 -0
  11. package/lib/client/components/HomeHero.vue +97 -0
  12. package/lib/client/components/Navbar.vue +76 -0
  13. package/lib/client/components/NavbarBrand.vue +55 -0
  14. package/lib/client/components/NavbarDropdown.vue +126 -0
  15. package/lib/{components/NavbarLinks.vue → client/components/NavbarItems.vue} +27 -47
  16. package/lib/{components → client/components}/Page.vue +5 -15
  17. package/lib/{components → client/components}/PageMeta.vue +48 -59
  18. package/lib/{components → client/components}/PageNav.vue +43 -56
  19. package/lib/client/components/Sidebar.vue +13 -0
  20. package/lib/client/components/SidebarItem.vue +80 -0
  21. package/lib/client/components/SidebarItems.vue +54 -0
  22. package/lib/client/components/ToggleDarkModeButton.vue +57 -0
  23. package/lib/client/components/ToggleSidebarButton.vue +24 -0
  24. package/lib/client/components/global/Badge.vue +31 -0
  25. package/lib/client/components/global/CodeGroup.d.ts +5 -0
  26. package/lib/client/components/global/CodeGroup.js +107 -0
  27. package/lib/client/components/global/CodeGroupItem.vue +31 -0
  28. package/lib/{composables → client/composables}/index.d.ts +2 -0
  29. package/lib/{composables → client/composables}/index.js +2 -0
  30. package/lib/client/composables/useDarkMode.d.ts +12 -0
  31. package/lib/client/composables/useDarkMode.js +57 -0
  32. package/lib/{composables → client/composables}/useNavLink.d.ts +6 -1
  33. package/lib/{composables → client/composables}/useNavLink.js +0 -0
  34. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.d.ts +1 -1
  35. package/lib/{composables → client/composables}/useResolveRouteWithRedirect.js +1 -1
  36. package/lib/client/composables/useScrollPromise.d.ts +6 -0
  37. package/lib/client/composables/useScrollPromise.js +14 -0
  38. package/lib/{composables → client/composables}/useSidebarItems.d.ts +12 -7
  39. package/lib/client/composables/useSidebarItems.js +120 -0
  40. package/lib/{composables → client/composables}/useThemeData.d.ts +2 -2
  41. package/lib/{composables → client/composables}/useThemeData.js +1 -1
  42. package/lib/client/index.d.ts +4 -0
  43. package/lib/client/index.js +2 -0
  44. package/lib/client/layouts/404.vue +25 -0
  45. package/lib/client/layouts/Layout.vue +128 -0
  46. package/lib/{shim.d.ts → client/shim.d.ts} +0 -0
  47. package/lib/{styles/_wrapper.scss → client/styles/_mixins.scss} +7 -2
  48. package/lib/client/styles/_variables.scss +11 -0
  49. package/lib/{styles → client/styles}/arrow.scss +4 -6
  50. package/lib/{styles → client/styles}/badge.scss +9 -11
  51. package/lib/{styles → client/styles}/code-group.scss +9 -2
  52. package/lib/{styles → client/styles}/code.scss +21 -33
  53. package/lib/client/styles/custom-container.scss +88 -0
  54. package/lib/{styles → client/styles}/home.scss +27 -24
  55. package/lib/{styles → client/styles}/index.scss +4 -4
  56. package/lib/{styles → client/styles}/layout.scss +52 -35
  57. package/lib/{styles/dropdown.scss → client/styles/navbar-dropdown.scss} +37 -47
  58. package/lib/client/styles/navbar.scss +177 -0
  59. package/lib/client/styles/normalize.scss +172 -0
  60. package/lib/{styles → client/styles}/page.scss +15 -8
  61. package/lib/client/styles/sidebar.scss +134 -0
  62. package/lib/{styles → client/styles}/toc.scss +0 -0
  63. package/lib/client/styles/transitions.scss +22 -0
  64. package/lib/client/styles/vars-dark.scss +46 -0
  65. package/lib/client/styles/vars.scss +133 -0
  66. package/lib/{utils → client/utils}/index.d.ts +1 -0
  67. package/lib/{utils → client/utils}/index.js +1 -0
  68. package/lib/client/utils/isActiveSidebarItem.d.ts +3 -0
  69. package/lib/client/utils/isActiveSidebarItem.js +20 -0
  70. package/lib/{utils → client/utils}/resolveEditLink.d.ts +1 -1
  71. package/lib/{utils → client/utils}/resolveEditLink.js +14 -8
  72. package/lib/client/utils/resolveRepoType.d.ts +2 -0
  73. package/lib/{utils → client/utils}/resolveRepoType.js +3 -1
  74. package/lib/node/defaultTheme.d.ts +10 -0
  75. package/lib/node/defaultTheme.js +122 -0
  76. package/lib/node/index.d.ts +5 -5
  77. package/lib/node/index.js +10 -6
  78. package/lib/node/utils/assignDefaultLocaleOptions.d.ts +7 -0
  79. package/lib/node/{assignDefaultLocaleOptions.js → utils/assignDefaultLocaleOptions.js} +11 -9
  80. package/lib/node/utils/index.d.ts +2 -0
  81. package/lib/node/utils/index.js +18 -0
  82. package/lib/node/utils/resolveContainerPluginOptions.d.ts +8 -0
  83. package/lib/node/utils/resolveContainerPluginOptions.js +22 -0
  84. package/lib/{types → shared}/index.d.ts +0 -0
  85. package/lib/{types → shared}/index.js +5 -1
  86. package/lib/{types → shared}/nav.d.ts +11 -12
  87. package/lib/{types → shared}/nav.js +0 -0
  88. package/lib/{types → shared}/options.d.ts +42 -10
  89. package/lib/{types → shared}/options.js +0 -0
  90. package/lib/{types → shared}/page.d.ts +13 -5
  91. package/lib/{types → shared}/page.js +0 -0
  92. package/package.json +38 -29
  93. package/templates/build.html +33 -0
  94. package/CHANGELOG.md +0 -353
  95. package/lib/clientAppEnhance.js +0 -23
  96. package/lib/clientAppSetup.js +0 -11
  97. package/lib/components/DropdownLink.vue +0 -141
  98. package/lib/components/DropdownTransition.vue +0 -34
  99. package/lib/components/Home.vue +0 -133
  100. package/lib/components/NavLink.vue +0 -105
  101. package/lib/components/Navbar.vue +0 -113
  102. package/lib/components/Sidebar.vue +0 -38
  103. package/lib/components/SidebarChild.d.ts +0 -6
  104. package/lib/components/SidebarChild.js +0 -83
  105. package/lib/components/ToggleSidebarButton.vue +0 -27
  106. package/lib/components/global/Badge.vue +0 -37
  107. package/lib/components/global/CodeGroup.vue +0 -85
  108. package/lib/components/global/CodeGroupItem.vue +0 -25
  109. package/lib/components/global/OutboundLink.vue +0 -30
  110. package/lib/composables/useSidebarItems.js +0 -108
  111. package/lib/index.d.ts +0 -6
  112. package/lib/index.js +0 -67
  113. package/lib/layouts/404.vue +0 -38
  114. package/lib/layouts/Layout.vue +0 -132
  115. package/lib/node/assignDefaultLocaleOptions.d.ts +0 -5
  116. package/lib/node/resolveActiveHeaderLinksPluginOptions.d.ts +0 -6
  117. package/lib/node/resolveActiveHeaderLinksPluginOptions.js +0 -16
  118. package/lib/node/resolveContainerPluginOptions.d.ts +0 -26
  119. package/lib/node/resolveContainerPluginOptions.js +0 -79
  120. package/lib/node/resolveGitPluginOptions.d.ts +0 -6
  121. package/lib/node/resolveGitPluginOptions.js +0 -22
  122. package/lib/node/resolveMediumZoomPluginOptions.d.ts +0 -6
  123. package/lib/node/resolveMediumZoomPluginOptions.js +0 -17
  124. package/lib/styles/_normalize.scss +0 -148
  125. package/lib/styles/_variables.scss +0 -34
  126. package/lib/styles/custom-container.scss +0 -78
  127. package/lib/styles/navbar.scss +0 -140
  128. package/lib/styles/plugins.scss +0 -18
  129. package/lib/styles/sidebar.scss +0 -147
  130. package/lib/styles/sr-only.scss +0 -12
  131. package/lib/styles/transitions.scss +0 -13
  132. package/lib/utils/resolveRepoType.d.ts +0 -2
@@ -0,0 +1,134 @@
1
+ @import '_mixins';
2
+ @import '_variables';
3
+
4
+ .sidebar {
5
+ ul {
6
+ padding: 0;
7
+ margin: 0;
8
+ list-style-type: none;
9
+ }
10
+
11
+ a {
12
+ display: inline-block;
13
+ }
14
+
15
+ .navbar-items {
16
+ display: none;
17
+ border-bottom: 1px solid var(--c-border);
18
+ transition: border-color var(--t-color);
19
+ padding: 0.5rem 0 0.75rem 0;
20
+
21
+ a {
22
+ font-weight: 600;
23
+ }
24
+
25
+ .navbar-item {
26
+ display: block;
27
+ line-height: 1.25rem;
28
+ font-size: 1.1em;
29
+ padding: 0.5rem 0 0.5rem 1.5rem;
30
+ }
31
+ }
32
+
33
+ .sidebar-items {
34
+ padding: 1.5rem 0;
35
+ }
36
+ }
37
+
38
+ @media (max-width: $MQMobile) {
39
+ .sidebar {
40
+ .navbar-items {
41
+ display: block;
42
+
43
+ .navbar-dropdown-wrapper
44
+ .navbar-dropdown
45
+ .navbar-dropdown-item
46
+ a.router-link-active::after {
47
+ top: calc(1rem - 2px);
48
+ }
49
+ }
50
+
51
+ .sidebar-items {
52
+ padding: 1rem 0;
53
+ }
54
+ }
55
+ }
56
+
57
+ .sidebar-item {
58
+ cursor: default;
59
+ border-left: 0.25rem solid transparent;
60
+ color: var(--c-text);
61
+
62
+ &:focus-visible {
63
+ outline-width: 1px;
64
+ outline-offset: -1px;
65
+ }
66
+
67
+ &.active:not(p.sidebar-heading) {
68
+ font-weight: 600;
69
+ color: var(--c-text-accent);
70
+ border-left-color: var(--c-text-accent);
71
+ }
72
+
73
+ &.sidebar-heading {
74
+ transition: color 0.15s ease;
75
+ font-size: 1.1em;
76
+ font-weight: bold;
77
+ padding: 0.35rem 1.5rem 0.35rem 1.25rem;
78
+ width: 100%;
79
+ box-sizing: border-box;
80
+ margin: 0;
81
+
82
+ &.collapsible {
83
+ cursor: pointer;
84
+
85
+ & + .sidebar-item-children {
86
+ @include dropdown_wrapper;
87
+ margin-bottom: 0.75rem;
88
+ }
89
+ }
90
+
91
+ .arrow {
92
+ position: relative;
93
+ top: -0.12em;
94
+ left: 0.5em;
95
+ }
96
+ }
97
+
98
+ &:not(.sidebar-heading) {
99
+ font-size: 1em;
100
+ font-weight: 400;
101
+ display: inline-block;
102
+ margin: 0;
103
+ padding: 0.35rem 1rem 0.35rem 2rem;
104
+ line-height: 1.4;
105
+ width: 100%;
106
+ box-sizing: border-box;
107
+
108
+ & + .sidebar-item-children {
109
+ padding-left: 1rem;
110
+ font-size: 0.95em;
111
+ }
112
+
113
+ .sidebar-item-children .sidebar-item-children & {
114
+ padding: 0.25rem 1rem 0.25rem 1.75rem;
115
+
116
+ &.active {
117
+ font-weight: 500;
118
+ border-left-color: transparent;
119
+ }
120
+ }
121
+
122
+ a.sidebar-heading + .sidebar-item-children &.active {
123
+ border-left-color: transparent;
124
+ }
125
+ }
126
+ }
127
+
128
+ a.sidebar-item {
129
+ cursor: pointer;
130
+
131
+ &:hover {
132
+ color: var(--c-text-accent);
133
+ }
134
+ }
File without changes
@@ -0,0 +1,22 @@
1
+ /**
2
+ * dropdown
3
+ */
4
+ .dropdown-enter-from,
5
+ .dropdown-leave-to {
6
+ height: 0 !important;
7
+ }
8
+
9
+ /**
10
+ * fade-slide-y
11
+ */
12
+ .fade-slide-y-enter-active {
13
+ transition: all 0.2s ease;
14
+ }
15
+ .fade-slide-y-leave-active {
16
+ transition: all 0.2s cubic-bezier(1, 0.5, 0.8, 1);
17
+ }
18
+ .fade-slide-y-enter-from,
19
+ .fade-slide-y-leave-to {
20
+ transform: translateY(10px);
21
+ opacity: 0;
22
+ }
@@ -0,0 +1,46 @@
1
+ html.dark {
2
+ // brand colors
3
+ --c-brand: #3aa675;
4
+ --c-brand-light: #349469;
5
+
6
+ // background colors
7
+ --c-bg: #22272e;
8
+ --c-bg-light: #2b313a;
9
+ --c-bg-lighter: #262c34;
10
+
11
+ // text colors
12
+ --c-text: #adbac7;
13
+ --c-text-light: #96a7b7;
14
+ --c-text-lighter: #8b9eb0;
15
+ --c-text-lightest: #8094a8;
16
+
17
+ // border colors
18
+ --c-border: #3e4c5a;
19
+ --c-border-dark: #34404c;
20
+
21
+ // custom container colors
22
+ --c-tip: #318a62;
23
+ --c-warning: #ceab00;
24
+ --c-warning-bg: #7e755b;
25
+ --c-warning-title: #ceac03;
26
+ --c-warning-text: #362e00;
27
+ --c-danger: #940000;
28
+ --c-danger-bg: #806161;
29
+ --c-danger-title: #610000;
30
+ --c-danger-text: #3a0000;
31
+ --c-details-bg: #323843;
32
+
33
+ // code blocks vars
34
+ --code-hl-bg-color: #363b46;
35
+ }
36
+
37
+ // plugin-docsearch
38
+ html.dark .DocSearch {
39
+ --docsearch-logo-color: var(--c-text);
40
+ --docsearch-modal-shadow: inset 1px 1px 0 0 #2c2e40, 0 3px 8px 0 #000309;
41
+ --docsearch-key-shadow: inset 0 -2px 0 0 #282d55, inset 0 0 1px 1px #51577d,
42
+ 0 2px 2px 0 rgba(3, 4, 9, 0.3);
43
+ --docsearch-key-gradient: linear-gradient(-225deg, #444950, #1c1e21);
44
+ --docsearch-footer-shadow: inset 0 1px 0 0 rgba(73, 76, 106, 0.5),
45
+ 0 -4px 8px 0 rgba(0, 0, 0, 0.2);
46
+ }
@@ -0,0 +1,133 @@
1
+ :root {
2
+ // brand colors
3
+ --c-brand: #3eaf7c;
4
+ --c-brand-light: #4abf8a;
5
+
6
+ // background colors
7
+ --c-bg: #ffffff;
8
+ --c-bg-light: #f3f4f5;
9
+ --c-bg-lighter: #eeeeee;
10
+ --c-bg-navbar: var(--c-bg);
11
+ --c-bg-sidebar: var(--c-bg);
12
+ --c-bg-arrow: #cccccc;
13
+
14
+ // text colors
15
+ --c-text: #2c3e50;
16
+ --c-text-accent: var(--c-brand);
17
+ --c-text-light: #3a5169;
18
+ --c-text-lighter: #4e6e8e;
19
+ --c-text-lightest: #6a8bad;
20
+ --c-text-quote: #999999;
21
+
22
+ // border colors
23
+ --c-border: #eaecef;
24
+ --c-border-dark: #dfe2e5;
25
+
26
+ // custom container colors
27
+ --c-tip: #42b983;
28
+ --c-tip-bg: var(--c-bg-light);
29
+ --c-tip-title: var(--c-text);
30
+ --c-tip-text: var(--c-text);
31
+ --c-tip-text-accent: var(--c-text-accent);
32
+ --c-warning: #e7c000;
33
+ --c-warning-bg: #fffae3;
34
+ --c-warning-title: #ad9000;
35
+ --c-warning-text: #746000;
36
+ --c-warning-text-accent: var(--c-text);
37
+ --c-danger: #cc0000;
38
+ --c-danger-bg: #ffe0e0;
39
+ --c-danger-title: #990000;
40
+ --c-danger-text: #660000;
41
+ --c-danger-text-accent: var(--c-text);
42
+ --c-details-bg: #eeeeee;
43
+
44
+ // badge component colors
45
+ --c-badge-tip: var(--c-tip);
46
+ --c-badge-warning: var(--c-warning);
47
+ --c-badge-danger: var(--c-danger);
48
+
49
+ // transition vars
50
+ --t-color: 0.3s ease;
51
+ --t-transform: 0.3s ease;
52
+
53
+ // code blocks vars
54
+ --code-bg-color: #282c34;
55
+ --code-hl-bg-color: rgba(0, 0, 0, 0.66);
56
+ --code-ln-color: #9e9e9e;
57
+ --code-ln-wrapper-width: 3.5rem;
58
+
59
+ // font vars
60
+ --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
61
+ Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
62
+ --font-family-code: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
63
+
64
+ // layout vars
65
+ --navbar-height: 3.6rem;
66
+ --navbar-padding-v: 0.7rem;
67
+ --navbar-padding-h: 1.5rem;
68
+ --sidebar-width: 20rem;
69
+ --sidebar-width-mobile: calc(var(--sidebar-width) * 0.82);
70
+ --content-width: 740px;
71
+ --homepage-width: 960px;
72
+ }
73
+
74
+ // plugin-back-to-top
75
+ .back-to-top {
76
+ --back-to-top-color: var(--c-brand);
77
+ --back-to-top-color-hover: var(--c-brand-light);
78
+ }
79
+
80
+ // plugin-docsearch
81
+ .DocSearch {
82
+ --docsearch-primary-color: var(--c-brand);
83
+ --docsearch-text-color: var(--c-text);
84
+ --docsearch-highlight-color: var(--c-brand);
85
+ --docsearch-muted-color: var(--c-text-quote);
86
+ --docsearch-container-background: rgba(9, 10, 17, 0.8);
87
+ --docsearch-modal-background: var(--c-bg-light);
88
+ --docsearch-searchbox-background: var(--c-bg-lighter);
89
+ --docsearch-searchbox-focus-background: var(--c-bg);
90
+ --docsearch-searchbox-shadow: inset 0 0 0 2px var(--c-brand);
91
+ --docsearch-hit-color: var(--c-text-light);
92
+ --docsearch-hit-active-color: var(--c-bg);
93
+ --docsearch-hit-background: var(--c-bg);
94
+ --docsearch-hit-shadow: 0 1px 3px 0 var(--c-border-dark);
95
+ --docsearch-footer-background: var(--c-bg);
96
+ }
97
+
98
+ // plugin-external-link-icon
99
+ .external-link-icon {
100
+ --external-link-icon-color: var(--c-text-quote);
101
+ }
102
+
103
+ // plugin-medium-zoom
104
+ .medium-zoom-overlay {
105
+ --medium-zoom-bg-color: var(--c-bg);
106
+ }
107
+
108
+ // plugin-nprogress
109
+ #nprogress {
110
+ --nprogress-color: var(--c-brand);
111
+ }
112
+
113
+ // plugin-pwa-popup
114
+ .pwa-popup {
115
+ --pwa-popup-text-color: var(--c-text);
116
+ --pwa-popup-bg-color: var(--c-bg);
117
+ --pwa-popup-border-color: var(--c-brand);
118
+ --pwa-popup-shadow: 0 4px 16px var(--c-brand);
119
+ --pwa-popup-btn-text-color: var(--c-bg);
120
+ --pwa-popup-btn-bg-color: var(--c-brand);
121
+ --pwa-popup-btn-hover-bg-color: var(--c-brand-light);
122
+ }
123
+
124
+ // plugin-search
125
+ .search-box {
126
+ --search-bg-color: var(--c-bg);
127
+ --search-accent-color: var(--c-brand);
128
+ --search-text-color: var(--c-text);
129
+ --search-border-color: var(--c-border);
130
+
131
+ --search-item-text-color: var(--c-text-lighter);
132
+ --search-item-focus-bg-color: var(--c-bg-light);
133
+ }
@@ -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;
@@ -1,23 +1,29 @@
1
- import { removeLeadingSlash, removeEndingSlash } from '@vuepress/shared';
1
+ import { isLinkHttp, removeEndingSlash, removeLeadingSlash, } from '@vuepress/shared';
2
2
  import { resolveRepoType } from './resolveRepoType';
3
3
  export const editLinkPatterns = {
4
4
  GitHub: ':repo/edit/:branch/:path',
5
5
  GitLab: ':repo/-/edit/:branch/:path',
6
+ Gitee: ':repo/edit/:branch/:path',
6
7
  Bitbucket: ':repo/src/:branch/:path?mode=edit&spa=0&at=:branch&fileviewer=file-view-default',
7
8
  };
8
- export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
9
- const repoType = resolveRepoType(docsRepo);
10
- let pattern;
9
+ const resolveEditLinkPatterns = ({ docsRepo, editLinkPattern, }) => {
11
10
  if (editLinkPattern) {
12
- pattern = editLinkPattern;
11
+ return editLinkPattern;
13
12
  }
14
- else if (repoType !== null) {
15
- pattern = editLinkPatterns[repoType];
13
+ const repoType = resolveRepoType(docsRepo);
14
+ if (repoType !== null) {
15
+ return editLinkPatterns[repoType];
16
16
  }
17
+ return null;
18
+ };
19
+ export const resolveEditLink = ({ docsRepo, docsBranch, docsDir, filePathRelative, editLinkPattern, }) => {
20
+ if (!filePathRelative)
21
+ return null;
22
+ const pattern = resolveEditLinkPatterns({ docsRepo, editLinkPattern });
17
23
  if (!pattern)
18
24
  return null;
19
25
  return pattern
20
- .replace(/:repo/, repoType === 'GitHub' ? `https://github.com/${docsRepo}` : docsRepo)
26
+ .replace(/:repo/, isLinkHttp(docsRepo) ? docsRepo : `https://github.com/${docsRepo}`)
21
27
  .replace(/:branch/, docsBranch)
22
28
  .replace(/:path/, removeLeadingSlash(`${removeEndingSlash(docsDir)}/${filePathRelative}`));
23
29
  };
@@ -0,0 +1,2 @@
1
+ export declare type RepoType = 'GitHub' | 'GitLab' | 'Gitee' | 'Bitbucket' | null;
2
+ export declare const resolveRepoType: (repo: string) => RepoType;
@@ -1,10 +1,12 @@
1
1
  import { isLinkHttp } from '@vuepress/shared';
2
2
  export const resolveRepoType = (repo) => {
3
- if (!isLinkHttp(repo))
3
+ if (!isLinkHttp(repo) || /github\.com/.test(repo))
4
4
  return 'GitHub';
5
5
  if (/bitbucket\.org/.test(repo))
6
6
  return 'Bitbucket';
7
7
  if (/gitlab\.com/.test(repo))
8
8
  return 'GitLab';
9
+ if (/gitee\.com/.test(repo))
10
+ return 'Gitee';
9
11
  return null;
10
12
  };
@@ -0,0 +1,10 @@
1
+ import type { Theme } from '@vuepress/core';
2
+ import type { DefaultThemeLocaleOptions, DefaultThemePluginsOptions } from '../shared';
3
+ export interface DefaultThemeOptions extends DefaultThemeLocaleOptions {
4
+ /**
5
+ * To avoid confusion with the root `plugins` option,
6
+ * we use `themePlugins`
7
+ */
8
+ themePlugins?: DefaultThemePluginsOptions;
9
+ }
10
+ export declare const defaultTheme: ({ themePlugins, ...localeOptions }?: DefaultThemeOptions) => Theme;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultTheme = void 0;
4
+ const plugin_active_header_links_1 = require("@vuepress/plugin-active-header-links");
5
+ const plugin_back_to_top_1 = require("@vuepress/plugin-back-to-top");
6
+ const plugin_container_1 = require("@vuepress/plugin-container");
7
+ const plugin_external_link_icon_1 = require("@vuepress/plugin-external-link-icon");
8
+ const plugin_git_1 = require("@vuepress/plugin-git");
9
+ const plugin_medium_zoom_1 = require("@vuepress/plugin-medium-zoom");
10
+ const plugin_nprogress_1 = require("@vuepress/plugin-nprogress");
11
+ const plugin_palette_1 = require("@vuepress/plugin-palette");
12
+ const plugin_prismjs_1 = require("@vuepress/plugin-prismjs");
13
+ const plugin_theme_data_1 = require("@vuepress/plugin-theme-data");
14
+ const utils_1 = require("@vuepress/utils");
15
+ const utils_2 = require("./utils");
16
+ const defaultTheme = ({ themePlugins = {}, ...localeOptions } = {}) => {
17
+ var _a, _b, _c, _d, _e, _f;
18
+ (0, utils_2.assignDefaultLocaleOptions)(localeOptions);
19
+ return {
20
+ name: '@vuepress/theme-default',
21
+ layouts: utils_1.path.resolve(__dirname, '../client/layouts'),
22
+ templateBuild: utils_1.path.resolve(__dirname, '../../templates/build.html'),
23
+ // use alias to make all components replaceable
24
+ alias: Object.fromEntries(utils_1.fs
25
+ .readdirSync(utils_1.path.resolve(__dirname, '../client/components'))
26
+ .filter((file) => file.endsWith('.vue'))
27
+ .map((file) => [
28
+ `@theme/${file}`,
29
+ utils_1.path.resolve(__dirname, '../client/components', file),
30
+ ])),
31
+ clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
32
+ clientAppSetupFiles: utils_1.path.resolve(__dirname, '../client/clientAppSetup.js'),
33
+ extendsPage: (page) => {
34
+ // save relative file path into page data to generate edit link
35
+ page.data.filePathRelative = page.filePathRelative;
36
+ // save title into route meta to generate navbar and sidebar
37
+ page.routeMeta.title = page.title;
38
+ },
39
+ plugins: [
40
+ // @vuepress/plugin-active-header-link
41
+ themePlugins.activeHeaderLinks !== false
42
+ ? (0, plugin_active_header_links_1.activeHeaderLinksPlugin)({
43
+ headerLinkSelector: 'a.sidebar-item',
44
+ headerAnchorSelector: '.header-anchor',
45
+ // should greater than page transition duration
46
+ delay: 300,
47
+ })
48
+ : [],
49
+ // @vuepress/plugin-back-to-top
50
+ themePlugins.backToTop !== false ? (0, plugin_back_to_top_1.backToTopPlugin)() : [],
51
+ // @vuepress/plugin-container
52
+ ((_a = themePlugins.container) === null || _a === void 0 ? void 0 : _a.tip) !== false
53
+ ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'tip'))
54
+ : [],
55
+ ((_b = themePlugins.container) === null || _b === void 0 ? void 0 : _b.warning) !== false
56
+ ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'warning'))
57
+ : [],
58
+ ((_c = themePlugins.container) === null || _c === void 0 ? void 0 : _c.danger) !== false
59
+ ? (0, plugin_container_1.containerPlugin)((0, utils_2.resolveContainerPluginOptions)(localeOptions, 'danger'))
60
+ : [],
61
+ ((_d = themePlugins.container) === null || _d === void 0 ? void 0 : _d.details) !== false
62
+ ? (0, plugin_container_1.containerPlugin)({
63
+ type: 'details',
64
+ before: (info) => `<details class="custom-container details">${info ? `<summary>${info}</summary>` : ''}\n`,
65
+ after: () => '</details>\n',
66
+ })
67
+ : [],
68
+ ((_e = themePlugins.container) === null || _e === void 0 ? void 0 : _e.codeGroup) !== false
69
+ ? (0, plugin_container_1.containerPlugin)({
70
+ type: 'code-group',
71
+ before: () => `<CodeGroup>\n`,
72
+ after: () => '</CodeGroup>\n',
73
+ })
74
+ : [],
75
+ ((_f = themePlugins.container) === null || _f === void 0 ? void 0 : _f.codeGroupItem) !== false
76
+ ? (0, plugin_container_1.containerPlugin)({
77
+ type: 'code-group-item',
78
+ before: (info) => `<CodeGroupItem title="${info}">\n`,
79
+ after: () => '</CodeGroupItem>\n',
80
+ })
81
+ : [],
82
+ // @vuepress/plugin-external-link-icon
83
+ themePlugins.externalLinkIcon !== false
84
+ ? (0, plugin_external_link_icon_1.externalLinkIconPlugin)({
85
+ locales: Object.entries(localeOptions.locales || {}).reduce((result, [key, value]) => {
86
+ var _a;
87
+ result[key] = {
88
+ openInNewWindow: (_a = value.openInNewWindow) !== null && _a !== void 0 ? _a : localeOptions.openInNewWindow,
89
+ };
90
+ return result;
91
+ }, {}),
92
+ })
93
+ : [],
94
+ // @vuepress/plugin-git
95
+ themePlugins.git !== false
96
+ ? (0, plugin_git_1.gitPlugin)({
97
+ createdTime: false,
98
+ updatedTime: localeOptions.lastUpdated !== false,
99
+ contributors: localeOptions.contributors !== false,
100
+ })
101
+ : [],
102
+ // @vuepress/plugin-medium-zoom
103
+ themePlugins.mediumZoom !== false
104
+ ? (0, plugin_medium_zoom_1.mediumZoomPlugin)({
105
+ selector: '.theme-default-content > img, .theme-default-content :not(a) > img',
106
+ zoomOptions: {},
107
+ // should greater than page transition duration
108
+ delay: 300,
109
+ })
110
+ : [],
111
+ // @vuepress/plugin-nprogress
112
+ themePlugins.nprogress !== false ? (0, plugin_nprogress_1.nprogressPlugin)() : [],
113
+ // @vuepress/plugin-palette
114
+ (0, plugin_palette_1.palettePlugin)({ preset: 'sass' }),
115
+ // @vuepress/plugin-prismjs
116
+ themePlugins.prismjs !== false ? (0, plugin_prismjs_1.prismjsPlugin)() : [],
117
+ // @vuepress/plugin-theme-data
118
+ (0, plugin_theme_data_1.themeDataPlugin)({ themeData: localeOptions }),
119
+ ],
120
+ };
121
+ };
122
+ exports.defaultTheme = defaultTheme;
@@ -1,5 +1,5 @@
1
- export * from './assignDefaultLocaleOptions';
2
- export * from './resolveActiveHeaderLinksPluginOptions';
3
- export * from './resolveContainerPluginOptions';
4
- export * from './resolveGitPluginOptions';
5
- export * from './resolveMediumZoomPluginOptions';
1
+ import { defaultTheme } from './defaultTheme';
2
+ export * from '../shared';
3
+ export * from './defaultTheme';
4
+ export * from './utils';
5
+ export default defaultTheme;
package/lib/node/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./assignDefaultLocaleOptions"), exports);
14
- __exportStar(require("./resolveActiveHeaderLinksPluginOptions"), exports);
15
- __exportStar(require("./resolveContainerPluginOptions"), exports);
16
- __exportStar(require("./resolveGitPluginOptions"), exports);
17
- __exportStar(require("./resolveMediumZoomPluginOptions"), exports);
17
+ const defaultTheme_1 = require("./defaultTheme");
18
+ __exportStar(require("../shared"), exports);
19
+ __exportStar(require("./defaultTheme"), exports);
20
+ __exportStar(require("./utils"), exports);
21
+ exports.default = defaultTheme_1.defaultTheme;
@@ -0,0 +1,7 @@
1
+ import type { DefaultThemeLocaleData, DefaultThemeLocaleOptions } from '../../shared';
2
+ export declare const DEFAULT_LOCALE_OPTIONS: DefaultThemeLocaleOptions;
3
+ export declare const DEFAULT_LOCALE_DATA: DefaultThemeLocaleData;
4
+ /**
5
+ * Assign default options
6
+ */
7
+ export declare const assignDefaultLocaleOptions: (localeOptions: DefaultThemeLocaleOptions) => void;