vitepress 0.22.4 → 1.0.0-draft.1

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/client.d.ts +2 -3
  2. package/dist/client/app/components/ClientOnly.js +1 -1
  3. package/dist/client/app/index.js +1 -1
  4. package/dist/client/theme-default/Layout.vue +25 -183
  5. package/dist/client/theme-default/NotFound.vue +9 -8
  6. package/dist/client/theme-default/components/VPAlgoliaSearchBox.vue +127 -0
  7. package/dist/client/theme-default/components/VPBackdrop.vue +39 -0
  8. package/dist/client/theme-default/components/VPContent.vue +44 -0
  9. package/dist/client/theme-default/components/VPContentDoc.vue +173 -0
  10. package/dist/client/theme-default/components/VPContentDocFooter.vue +140 -0
  11. package/dist/client/theme-default/components/VPContentDocOutline.vue +108 -0
  12. package/dist/client/theme-default/components/VPFlyout.vue +149 -0
  13. package/dist/client/theme-default/components/VPLink.vue +37 -0
  14. package/dist/client/theme-default/components/VPLocalNav.vue +106 -0
  15. package/dist/client/theme-default/components/VPMenu.vue +79 -0
  16. package/dist/client/theme-default/components/VPMenuGroup.vue +35 -0
  17. package/dist/client/theme-default/components/VPMenuLink.vue +30 -0
  18. package/dist/client/theme-default/components/VPNav.vue +33 -0
  19. package/dist/client/theme-default/components/VPNavBar.vue +109 -0
  20. package/dist/client/theme-default/components/VPNavBarAppearance.vue +22 -0
  21. package/dist/client/theme-default/components/VPNavBarExtra.vue +107 -0
  22. package/dist/client/theme-default/components/VPNavBarHamburger.vue +79 -0
  23. package/dist/client/theme-default/components/VPNavBarMenu.vue +29 -0
  24. package/dist/client/theme-default/components/VPNavBarMenuGroup.vue +18 -0
  25. package/dist/client/theme-default/components/VPNavBarMenuLink.vue +56 -0
  26. package/dist/client/theme-default/components/VPNavBarSearch.vue +269 -0
  27. package/dist/client/theme-default/components/VPNavBarSocialLinks.vue +27 -0
  28. package/dist/client/theme-default/components/VPNavBarTitle.vue +44 -0
  29. package/dist/client/theme-default/components/VPNavBarTranslations.vue +74 -0
  30. package/dist/client/theme-default/components/VPNavScreen.vue +100 -0
  31. package/dist/client/theme-default/components/VPNavScreenAppearance.vue +30 -0
  32. package/dist/client/theme-default/components/VPNavScreenMenu.vue +24 -0
  33. package/dist/client/theme-default/components/VPNavScreenMenuGroup.vue +118 -0
  34. package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +33 -0
  35. package/dist/client/theme-default/components/VPNavScreenMenuGroupSection.vue +35 -0
  36. package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +34 -0
  37. package/dist/client/theme-default/components/VPNavScreenSocialLinks.vue +14 -0
  38. package/dist/client/theme-default/components/VPNavScreenTranslations.vue +73 -0
  39. package/dist/client/theme-default/components/VPSidebar.vue +118 -0
  40. package/dist/client/theme-default/components/VPSidebarGroup.vue +44 -0
  41. package/dist/client/theme-default/components/VPSidebarLink.vue +57 -0
  42. package/dist/client/theme-default/components/VPSkipLink.vue +72 -0
  43. package/dist/client/theme-default/components/VPSocialLink.vue +63 -0
  44. package/dist/client/theme-default/components/VPSocialLinks.vue +27 -0
  45. package/dist/client/theme-default/components/VPSwitch.vue +66 -0
  46. package/dist/client/theme-default/components/VPSwitchAppearance.vue +74 -0
  47. package/dist/client/theme-default/components/icons/VPIconAlignJustify.vue +8 -0
  48. package/dist/client/theme-default/components/icons/VPIconAlignLeft.vue +8 -0
  49. package/dist/client/theme-default/components/icons/VPIconAlignRight.vue +8 -0
  50. package/dist/client/theme-default/components/icons/{ArrowLeft.vue → VPIconArrowLeft.vue} +0 -0
  51. package/dist/client/theme-default/components/icons/{ArrowRight.vue → VPIconArrowRight.vue} +0 -0
  52. package/dist/client/theme-default/components/icons/VPIconChevronDown.vue +5 -0
  53. package/dist/client/theme-default/components/icons/VPIconChevronLeft.vue +5 -0
  54. package/dist/client/theme-default/components/icons/VPIconChevronRight.vue +5 -0
  55. package/dist/client/theme-default/components/icons/VPIconChevronUp.vue +5 -0
  56. package/dist/client/theme-default/components/icons/VPIconDiscord.vue +5 -0
  57. package/dist/client/theme-default/components/icons/VPIconEdit.vue +6 -0
  58. package/dist/client/theme-default/components/icons/VPIconExternalLink.vue +13 -0
  59. package/dist/client/theme-default/components/icons/VPIconFacebook.vue +5 -0
  60. package/dist/client/theme-default/components/icons/VPIconGitHub.vue +5 -0
  61. package/dist/client/theme-default/components/icons/VPIconInstagram.vue +5 -0
  62. package/dist/client/theme-default/components/icons/VPIconLanguages.vue +9 -0
  63. package/dist/client/theme-default/components/icons/VPIconLinkedIn.vue +5 -0
  64. package/dist/client/theme-default/components/icons/VPIconMoon.vue +5 -0
  65. package/dist/client/theme-default/components/icons/VPIconMoreHorizontal.vue +7 -0
  66. package/dist/client/theme-default/components/icons/VPIconPlus.vue +5 -0
  67. package/dist/client/theme-default/components/icons/VPIconSlack.vue +5 -0
  68. package/dist/client/theme-default/components/icons/VPIconSun.vue +13 -0
  69. package/dist/client/theme-default/components/icons/VPIconTwitter.vue +5 -0
  70. package/dist/client/theme-default/components/icons/VPIconYouTube.vue +5 -0
  71. package/dist/client/theme-default/composables/edit-link.js +22 -0
  72. package/dist/client/theme-default/composables/flyout.js +40 -0
  73. package/dist/client/theme-default/composables/nav.js +27 -1
  74. package/dist/client/theme-default/composables/outline.js +130 -0
  75. package/dist/client/theme-default/composables/prev-next.js +18 -0
  76. package/dist/client/theme-default/composables/sidebar.js +57 -0
  77. package/dist/client/theme-default/fonts/inter-cyrillic-ext.woff2 +0 -0
  78. package/dist/client/theme-default/fonts/inter-cyrillic.woff2 +0 -0
  79. package/dist/client/theme-default/fonts/inter-greek-ext.woff2 +0 -0
  80. package/dist/client/theme-default/fonts/inter-greek.woff2 +0 -0
  81. package/dist/client/theme-default/fonts/inter-latin-ext.woff2 +0 -0
  82. package/dist/client/theme-default/fonts/inter-latin.woff2 +0 -0
  83. package/dist/client/theme-default/fonts/inter-vietnamese.woff2 +0 -0
  84. package/dist/client/theme-default/index.js +4 -4
  85. package/dist/client/theme-default/styles/base.css +200 -0
  86. package/dist/client/theme-default/styles/fonts.css +67 -0
  87. package/dist/client/theme-default/styles/utils.css +9 -0
  88. package/dist/client/theme-default/styles/vars.css +206 -66
  89. package/dist/client/theme-default/styles/vp-doc.css +419 -0
  90. package/dist/client/theme-default/support/sidebar.js +29 -0
  91. package/dist/client/theme-default/support/utils.js +43 -0
  92. package/dist/node/cli.js +3 -8
  93. package/dist/node/index.d.ts +104 -79
  94. package/dist/node/index.js +1 -1
  95. package/dist/node/{serve-3035f99b.js → serve-428d4610.js} +11418 -1415
  96. package/package.json +24 -20
  97. package/types/default-theme.d.ts +104 -79
  98. package/dist/client/theme-default/components/AlgoliaSearchBox.vue +0 -188
  99. package/dist/client/theme-default/components/BuySellAds.vue +0 -152
  100. package/dist/client/theme-default/components/CarbonAds.vue +0 -99
  101. package/dist/client/theme-default/components/EditLink.vue +0 -38
  102. package/dist/client/theme-default/components/Home.vue +0 -31
  103. package/dist/client/theme-default/components/HomeFeatures.vue +0 -143
  104. package/dist/client/theme-default/components/HomeFooter.vue +0 -50
  105. package/dist/client/theme-default/components/HomeHero.vue +0 -161
  106. package/dist/client/theme-default/components/LastUpdated.vue +0 -60
  107. package/dist/client/theme-default/components/NavBar.vue +0 -60
  108. package/dist/client/theme-default/components/NavBarTitle.vue +0 -41
  109. package/dist/client/theme-default/components/NavDropdownLink.vue +0 -135
  110. package/dist/client/theme-default/components/NavDropdownLinkItem.vue +0 -76
  111. package/dist/client/theme-default/components/NavLink.vue +0 -61
  112. package/dist/client/theme-default/components/NavLinks.vue +0 -52
  113. package/dist/client/theme-default/components/NextAndPrevLinks.vue +0 -88
  114. package/dist/client/theme-default/components/Page.vue +0 -53
  115. package/dist/client/theme-default/components/PageFooter.vue +0 -44
  116. package/dist/client/theme-default/components/SideBar.vue +0 -60
  117. package/dist/client/theme-default/components/SideBarLink.js +0 -68
  118. package/dist/client/theme-default/components/SideBarLinks.vue +0 -12
  119. package/dist/client/theme-default/components/ToggleSideBarButton.vue +0 -46
  120. package/dist/client/theme-default/components/icons/OutboundLink.vue +0 -31
  121. package/dist/client/theme-default/composables/activeSidebarLink.js +0 -99
  122. package/dist/client/theme-default/composables/editLink.js +0 -49
  123. package/dist/client/theme-default/composables/navLink.js +0 -42
  124. package/dist/client/theme-default/composables/nextAndPrevLinks.js +0 -37
  125. package/dist/client/theme-default/composables/repo.js +0 -38
  126. package/dist/client/theme-default/composables/sideBar.js +0 -57
  127. package/dist/client/theme-default/styles/code.css +0 -299
  128. package/dist/client/theme-default/styles/custom-blocks.css +0 -76
  129. package/dist/client/theme-default/styles/layout.css +0 -236
  130. package/dist/client/theme-default/styles/sidebar-links.css +0 -107
  131. package/dist/client/theme-default/support/sideBar.js +0 -46
  132. package/dist/client/theme-default/utils.js +0 -63
@@ -0,0 +1,29 @@
1
+ import { ensureStartingSlash } from './utils';
2
+ /**
3
+ * Get the `Sidebar` from sidebar option. This method will ensure to get correct
4
+ * sidebar config from `MultiSideBarConfig` with various path combinations such
5
+ * as matching `guide/` and `/guide/`. If no matching config was found, it will
6
+ * return empty array.
7
+ */
8
+ export function getSidebar(sidebar, path) {
9
+ if (Array.isArray(sidebar)) {
10
+ return sidebar;
11
+ }
12
+ path = ensureStartingSlash(path);
13
+ for (const dir in sidebar) {
14
+ // make sure the multi sidebar key starts with slash too
15
+ if (path.startsWith(ensureStartingSlash(dir))) {
16
+ return sidebar[dir];
17
+ }
18
+ }
19
+ return [];
20
+ }
21
+ export function getFlatSideBarLinks(sidebar) {
22
+ const links = [];
23
+ for (const group of sidebar) {
24
+ for (const link of group.items) {
25
+ links.push(link);
26
+ }
27
+ }
28
+ return links;
29
+ }
@@ -0,0 +1,43 @@
1
+ import { ref } from 'vue';
2
+ import { withBase } from 'vitepress';
3
+ export const HASH_RE = /#.*$/;
4
+ export const EXT_RE = /(index)?\.(md|html)$/;
5
+ export const OUTBOUND_RE = /^[a-z]+:/i;
6
+ const inBrowser = typeof window !== 'undefined';
7
+ const hashRef = ref(inBrowser ? location.hash : '');
8
+ export function isExternal(path) {
9
+ return OUTBOUND_RE.test(path);
10
+ }
11
+ export function isActive(currentPath, matchPath, asRegex = false) {
12
+ if (matchPath === undefined) {
13
+ return false;
14
+ }
15
+ currentPath = normalize(`/${currentPath}`);
16
+ if (asRegex) {
17
+ return new RegExp(matchPath).test(currentPath);
18
+ }
19
+ if (normalize(matchPath) !== currentPath) {
20
+ return false;
21
+ }
22
+ const hashMatch = matchPath.match(HASH_RE);
23
+ if (hashMatch) {
24
+ return hashRef.value === hashMatch[0];
25
+ }
26
+ return true;
27
+ }
28
+ export function ensureStartingSlash(path) {
29
+ return /^\//.test(path) ? path : `/${path}`;
30
+ }
31
+ export function normalize(path) {
32
+ return decodeURI(path).replace(HASH_RE, '').replace(EXT_RE, '');
33
+ }
34
+ export function normalizeLink(url) {
35
+ if (isExternal(url)) {
36
+ return url;
37
+ }
38
+ const { pathname, search, hash } = new URL(url, 'http://example.com');
39
+ const normalizedPath = pathname.endsWith('/') || pathname.endsWith('.html')
40
+ ? url
41
+ : `${pathname.replace(/(\.md)?$/, '.html')}${search}${hash}`;
42
+ return withBase(normalizedPath);
43
+ }
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var serve = require('./serve-3035f99b.js');
3
+ var serve = require('./serve-428d4610.js');
4
4
  require('fs');
5
5
  require('path');
6
6
  require('url');
@@ -94,7 +94,7 @@ var minimist = function (args, opts) {
94
94
  var o = obj;
95
95
  for (var i = 0; i < keys.length-1; i++) {
96
96
  var key = keys[i];
97
- if (isConstructorOrProto(o, key)) return;
97
+ if (key === '__proto__') return;
98
98
  if (o[key] === undefined) o[key] = {};
99
99
  if (o[key] === Object.prototype || o[key] === Number.prototype
100
100
  || o[key] === String.prototype) o[key] = {};
@@ -103,7 +103,7 @@ var minimist = function (args, opts) {
103
103
  }
104
104
 
105
105
  var key = keys[keys.length - 1];
106
- if (isConstructorOrProto(o, key)) return;
106
+ if (key === '__proto__') return;
107
107
  if (o === Object.prototype || o === Number.prototype
108
108
  || o === String.prototype) o = {};
109
109
  if (o === Array.prototype) o = [];
@@ -267,11 +267,6 @@ function isNumber (x) {
267
267
  return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
268
268
  }
269
269
 
270
-
271
- function isConstructorOrProto (obj, key) {
272
- return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__';
273
- }
274
-
275
270
  const argv = minimist(process.argv.slice(2));
276
271
  console.log(serve.source.cyan(`vitepress v${require("../../package.json").version}`));
277
272
  const command = argv._[0];
@@ -17,126 +17,157 @@ export declare function createServer(root?: string, serverOptions?: ServerOption
17
17
 
18
18
  export declare namespace DefaultTheme {
19
19
  export interface Config {
20
- logo?: string
21
- nav?: NavItem[] | false
22
- sidebar?: SideBarConfig | MultiSideBarConfig
23
-
24
20
  /**
25
- * GitHub repository following the format <user>/<project>.
21
+ * The logo file of the site.
26
22
  *
27
- * @example `"vuejs/vue-next"`
23
+ * @example '/logo.svg'
28
24
  */
29
- repo?: string
25
+ logo?: string
30
26
 
31
27
  /**
32
- * Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
33
- * depending on the provided repo.
34
- *
35
- * @example `"Contribute!"`
28
+ * The nav items.
36
29
  */
37
- repoLabel?: string
30
+ nav?: NavItem[]
38
31
 
39
32
  /**
40
- * If your docs are in a different repository from your main project.
41
- *
42
- * @example `"vuejs/docs-next"`
33
+ * The sidebar items.
43
34
  */
44
- docsRepo?: string
35
+ sidebar?: Sidebar
45
36
 
46
37
  /**
47
- * If your docs are not at the root of the repo.
48
- *
49
- * @example `"docs"`
38
+ * Info for the edit link. If it's undefined, the edit link feature will
39
+ * be disabled.
50
40
  */
51
- docsDir?: string
41
+ editLink?: EditLink
52
42
 
53
43
  /**
54
- * If your docs are in a different branch. Defaults to `master`.
55
- *
56
- * @example `"next"`
44
+ * The social links to be displayed at the end of the nav bar. Perfect for
45
+ * placing links to social services such as GitHub, Twitter, Facebook, etc.
57
46
  */
58
- docsBranch?: string
47
+ socialLinks?: SocialLink[]
59
48
 
60
49
  /**
61
- * Enable links to edit pages at the bottom of the page.
50
+ * Adds locale menu to the nav. This option should be used when you have
51
+ * your translated sites outside of the project.
62
52
  */
63
- editLinks?: boolean
53
+ localeLinks?: LocaleLinks
64
54
 
65
55
  /**
66
- * Custom text for edit link. Defaults to "Edit this page".
56
+ * The algolia options. Leave it undefined to disable the search feature.
67
57
  */
68
- editLinkText?: string
58
+ algolia?: AlgoliaSearchOptions
69
59
 
70
60
  /**
71
- * Show last updated time at the bottom of the page. Defaults to `false`.
72
- * If given a string, it will be displayed as a prefix (default value:
73
- * "Last Updated").
61
+ * The carbon ads options. Leave it undefined to disable the ads feature.
74
62
  */
75
- lastUpdated?: string | boolean
76
-
77
- prevLinks?: boolean
78
- nextLinks?: boolean
79
-
80
- locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
81
-
82
- algolia?: AlgoliaSearchOptions
83
-
84
- carbonAds?: {
85
- carbon: string
86
- custom?: string
87
- placement: string
88
- }
63
+ carbonAds?: CarbonAdsOptions
89
64
  }
90
65
 
91
- // navbar --------------------------------------------------------------------
66
+ // nav -----------------------------------------------------------------------
92
67
 
93
68
  export type NavItem = NavItemWithLink | NavItemWithChildren
94
69
 
95
- export interface NavItemBase {
70
+ export type NavItemWithLink = {
96
71
  text: string
97
- target?: string
98
- rel?: string
99
- ariaLabel?: string
100
- activeMatch?: string
101
- }
102
-
103
- export interface NavItemWithLink extends NavItemBase {
104
72
  link: string
73
+
74
+ /**
75
+ * `activeMatch` is expected to be a regex string. We can't use actual
76
+ * RegExp object here because it isn't serializable
77
+ */
78
+ activeMatch?: string
105
79
  }
106
80
 
107
- export interface NavItemWithChildren extends NavItemBase {
81
+ export interface NavItemWithChildren {
82
+ text?: string
108
83
  items: NavItemWithLink[]
109
84
  }
110
85
 
111
86
  // sidebar -------------------------------------------------------------------
112
87
 
113
- export type SideBarConfig = SideBarItem[] | 'auto' | false
88
+ export type Sidebar = SidebarGroup[] | SidebarMulti
114
89
 
115
- export interface MultiSideBarConfig {
116
- [path: string]: SideBarConfig
90
+ export interface SidebarMulti {
91
+ [path: string]: SidebarGroup[]
117
92
  }
118
93
 
119
- export type SideBarItem = SideBarLink | SideBarGroup
94
+ export interface SidebarGroup {
95
+ text: string
96
+ items: SidebarItem[]
97
+ }
120
98
 
121
- export interface SideBarLink {
99
+ export interface SidebarItem {
122
100
  text: string
123
101
  link: string
124
102
  }
125
103
 
126
- export interface SideBarGroup {
127
- text: string
128
- link?: string
104
+ // edit link -----------------------------------------------------------------
105
+
106
+ export interface EditLink {
107
+ /**
108
+ * Repo of the site.
109
+ *
110
+ * @example 'vuejs/docs'
111
+ */
112
+ repo: string
113
+
114
+ /**
115
+ * Branch of the repo.
116
+ *
117
+ * @default 'main'
118
+ */
119
+ branch?: string
120
+
121
+ /**
122
+ * If your docs are not at the root of the repo.
123
+ *
124
+ * @example 'docs'
125
+ */
126
+ dir?: string
129
127
 
130
128
  /**
131
- * @default false
129
+ * Custom text for edit link.
130
+ *
131
+ * @default 'Edit this page'
132
132
  */
133
- collapsable?: boolean
133
+ text?: string
134
+ }
135
+
136
+ // social link ---------------------------------------------------------------
137
+
138
+ export interface SocialLink {
139
+ icon: SocialLinkIcon
140
+ link: string
141
+ }
142
+
143
+ export type SocialLinkIcon =
144
+ | 'discord'
145
+ | 'facebook'
146
+ | 'github'
147
+ | 'instagram'
148
+ | 'linkedin'
149
+ | 'slack'
150
+ | 'twitter'
151
+ | 'youtube'
152
+
153
+ // locales -------------------------------------------------------------------
154
+
155
+ export interface LocaleLinks {
156
+ text: string
157
+ items: LocaleLink[]
158
+ }
134
159
 
135
- children: SideBarItem[]
160
+ export interface LocaleLink {
161
+ text: string
162
+ link: string
136
163
  }
137
164
 
138
- // algolia ------------------------------------------------------------------
139
- // partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
165
+ // algolia ------------------------------------------------------------------
166
+
167
+ /**
168
+ * The Algolia search options. Partially copied from
169
+ * `@docsearch/react/dist/esm/DocSearch.d.ts`
170
+ */
140
171
  export interface AlgoliaSearchOptions {
141
172
  appId: string
142
173
  apiKey: string
@@ -147,18 +178,12 @@ export declare namespace DefaultTheme {
147
178
  initialQuery?: string
148
179
  }
149
180
 
150
- // locales -------------------------------------------------------------------
181
+ // carbon ads ----------------------------------------------------------------
151
182
 
152
- export interface LocaleConfig {
153
- /**
154
- * Text for the language dropdown.
155
- */
156
- selectText?: string
157
-
158
- /**
159
- * Label for this locale in the language dropdown.
160
- */
161
- label?: string
183
+ export interface CarbonAdsOptions {
184
+ carbon: string
185
+ custom?: string
186
+ placement: string
162
187
  }
163
188
  }
164
189
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var serve = require('./serve-3035f99b.js');
5
+ var serve = require('./serve-428d4610.js');
6
6
  require('vite');
7
7
  require('readline');
8
8
  require('assert');