vitepress 0.22.1 → 0.22.4

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.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ---
7
7
 
8
- VitePress is [VuePress](http://vuepress.vuejs.org/)' spiritual successor, built on top of [vite](https://github.com/vuejs/vite).
8
+ VitePress is [VuePress](https://vuepress.vuejs.org)' spiritual successor, built on top of [vite](https://github.com/vitejs/vite).
9
9
 
10
10
  ## Documentation
11
11
 
@@ -13,14 +13,14 @@ To check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).
13
13
 
14
14
  ## Changelog
15
15
 
16
- Detailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/master/CHANGELOG.md).
16
+ Detailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md).
17
17
 
18
18
  ## Contribution
19
19
 
20
- Please make sure to read the [Contributing Guide](./.github/contributing.md) before making a pull request.
20
+ Please make sure to read the [Contributing Guide](https://github.com/vuejs/vitepress/blob/main/.github/contributing.md) before making a pull request.
21
21
 
22
22
  ## License
23
23
 
24
- [MIT](https://opensource.org/licenses/MIT)
24
+ [MIT](https://github.com/vuejs/vitepress/blob/main/LICENSE)
25
25
 
26
26
  Copyright (c) 2019-present, Yuxi (Evan) You
@@ -33,10 +33,6 @@ export function createApp() {
33
33
  app.provide(RouterSymbol, router);
34
34
  const data = initData(router.route);
35
35
  app.provide(dataSymbol, data);
36
- if (inBrowser) {
37
- // dynamically update head tags
38
- useUpdateHead(router.route, data.site);
39
- }
40
36
  // install global components
41
37
  app.component('Content', Content);
42
38
  app.component('ClientOnly', ClientOnly);
@@ -56,7 +52,7 @@ export function createApp() {
56
52
  siteData: siteDataRef
57
53
  });
58
54
  }
59
- return { app, router };
55
+ return { app, router, data };
60
56
  }
61
57
  function newApp() {
62
58
  return import.meta.env.PROD
@@ -104,9 +100,11 @@ function shouldHotReload(payload) {
104
100
  return payloadPath === locationPath;
105
101
  }
106
102
  if (inBrowser) {
107
- const { app, router } = createApp();
103
+ const { app, router, data } = createApp();
108
104
  // wait until page component is fetched before mounting
109
105
  router.go().then(() => {
106
+ // dynamically update head tags
107
+ useUpdateHead(router.route, data.site);
110
108
  app.mount('#app');
111
109
  });
112
110
  }
@@ -5,13 +5,18 @@ export const RouterSymbol = Symbol();
5
5
  // we are just using URL to parse the pathname and hash - the base doesn't
6
6
  // matter and is only passed to support same-host hrefs.
7
7
  const fakeHost = `http://a.com`;
8
+ const notFoundPageData = {
9
+ relativePath: '',
10
+ title: '404',
11
+ description: 'Not Found',
12
+ headers: [],
13
+ frontmatter: {},
14
+ lastUpdated: 0
15
+ };
8
16
  const getDefaultRoute = () => ({
9
17
  path: '/',
10
18
  component: null,
11
- // this will be set upon initial page load, which is before
12
- // the app is mounted, so it's guaranteed to be available in
13
- // components. We just need enough data for 404 pages to render.
14
- data: { frontmatter: {} }
19
+ data: notFoundPageData
15
20
  });
16
21
  export function createRouter(loadPageModule, fallbackComponent) {
17
22
  const route = reactive(getDefaultRoute());
@@ -91,6 +96,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
91
96
  latestPendingPath = null;
92
97
  route.path = pendingPath;
93
98
  route.component = fallbackComponent ? markRaw(fallbackComponent) : null;
99
+ route.data = notFoundPageData;
94
100
  }
95
101
  }
96
102
  }
@@ -153,7 +159,7 @@ export function useRoute() {
153
159
  function scrollTo(el, hash, smooth = false) {
154
160
  let target = null;
155
161
  try {
156
- target = el.classList.contains('.header-anchor')
162
+ target = el.classList.contains('header-anchor')
157
163
  ? el
158
164
  : document.querySelector(decodeURIComponent(hash));
159
165
  }
@@ -4,12 +4,11 @@ import { useRoute, useData } from 'vitepress'
4
4
  import { isSideBarEmpty, getSideBarConfig } from './support/sideBar'
5
5
 
6
6
  // components
7
+ import Home from './components/Home.vue'
7
8
  import NavBar from './components/NavBar.vue'
8
9
  import SideBar from './components/SideBar.vue'
9
10
  import Page from './components/Page.vue'
10
11
 
11
- const Home = defineAsyncComponent(() => import('./components/Home.vue'))
12
-
13
12
  const NoopComponent = () => null
14
13
 
15
14
  const CarbonAds = __CARBON__
@@ -54,25 +54,18 @@ const { lang } = useData()
54
54
 
55
55
  // if the user has multiple locales, the search results should be filtered
56
56
  // based on the language
57
- const facetFilters: string[] = props.multilang
58
- ? ['lang:' + lang.value]
59
- : []
57
+ const facetFilters: string[] = props.multilang ? ['lang:' + lang.value] : []
60
58
 
61
59
  if (props.options.searchParameters?.facetFilters) {
62
60
  facetFilters.push(...props.options.searchParameters.facetFilters)
63
61
  }
64
62
 
65
- watch(
66
- lang,
67
- (newLang, oldLang) => {
68
- const index = facetFilters.findIndex(
69
- (filter) => filter === 'lang:' + oldLang
70
- )
71
- if (index > -1) {
72
- facetFilters.splice(index, 1, 'lang:' + newLang)
73
- }
63
+ watch(lang, (newLang, oldLang) => {
64
+ const index = facetFilters.findIndex((filter) => filter === 'lang:' + oldLang)
65
+ if (index > -1) {
66
+ facetFilters.splice(index, 1, 'lang:' + newLang)
74
67
  }
75
- )
68
+ })
76
69
 
77
70
  function initialize(userOptions: any) {
78
71
  docsearch(
@@ -7,7 +7,7 @@ const { theme, page } = useData()
7
7
  const hasLastUpdated = computed(() => {
8
8
  const lu = theme.value.lastUpdated
9
9
 
10
- return lu !== undefined && lu !== false
10
+ return lu !== undefined && lu !== false && page.value.lastUpdated !== 0
11
11
  })
12
12
 
13
13
  const prefix = computed(() => {
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var serve = require('./serve-c594fc71.js');
3
+ var serve = require('./serve-3035f99b.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 (key === '__proto__') return;
97
+ if (isConstructorOrProto(o, key)) 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 (key === '__proto__') return;
106
+ if (isConstructorOrProto(o, key)) return;
107
107
  if (o === Object.prototype || o === Number.prototype
108
108
  || o === String.prototype) o = {};
109
109
  if (o === Array.prototype) o = [];
@@ -267,6 +267,11 @@ 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
+
270
275
  const argv = minimist(process.argv.slice(2));
271
276
  console.log(serve.source.cyan(`vitepress v${require("../../package.json").version}`));
272
277
  const command = argv._[0];
@@ -11,7 +11,7 @@ export declare function build(root: string, buildOptions?: BuildOptions & {
11
11
  mpa?: string;
12
12
  }): Promise<void>;
13
13
 
14
- export declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions) => MarkdownRenderer;
14
+ export declare const createMarkdownRenderer: (srcDir: string, options: MarkdownOptions | undefined, base: string) => MarkdownRenderer;
15
15
 
16
16
  export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
17
17
 
@@ -138,7 +138,7 @@ export declare namespace DefaultTheme {
138
138
  // algolia ------------------------------------------------------------------
139
139
  // partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
140
140
  export interface AlgoliaSearchOptions {
141
- appId?: string
141
+ appId: string
142
142
  apiKey: string
143
143
  indexName: string
144
144
  placeholder?: string
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var serve = require('./serve-c594fc71.js');
5
+ var serve = require('./serve-3035f99b.js');
6
6
  require('vite');
7
7
  require('readline');
8
8
  require('assert');