vitepress 1.0.0-beta.6 → 1.0.0-beta.7

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.
@@ -43,7 +43,7 @@ export function pathToFile(path) {
43
43
  }
44
44
  if (!pageHash)
45
45
  return null;
46
- pagePath = `${base}${__ASSETS_DIR__.replace(/"(.+)"/, '$1')}/${pagePath}.${pageHash}.js`;
46
+ pagePath = `${base}${__ASSETS_DIR__}/${pagePath}.${pageHash}.js`;
47
47
  }
48
48
  else {
49
49
  // ssr build uses much simpler name mapping
@@ -34,7 +34,7 @@ provide('hero-image-slot-exists', heroImageSlotExists)
34
34
  </script>
35
35
 
36
36
  <template>
37
- <div v-if="frontmatter.layout !== false" class="Layout">
37
+ <div v-if="frontmatter.layout !== false" class="Layout" :class="frontmatter.pageClass" >
38
38
  <slot name="layout-top" />
39
39
  <VPSkipLink />
40
40
  <VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar" />
@@ -30,7 +30,7 @@ h3 .VPBadge,
30
30
  h4 .VPBadge,
31
31
  h5 .VPBadge,
32
32
  h6 .VPBadge {
33
- vertical-align: top;
33
+ vertical-align: text-top;
34
34
  }
35
35
 
36
36
  h2 .VPBadge {
@@ -10,11 +10,12 @@ defineProps<{
10
10
  details?: string
11
11
  link?: string
12
12
  linkText?: string
13
+ rel?: string
13
14
  }>()
14
15
  </script>
15
16
 
16
17
  <template>
17
- <VPLink class="VPFeature" :href="link" :no-icon="true" :tag="link ? 'a' : 'div'">
18
+ <VPLink class="VPFeature" :href="link" :rel="rel" :no-icon="true" :tag="link ? 'a' : 'div'">
18
19
  <article class="box">
19
20
  <VPImage
20
21
  v-if="typeof icon === 'object'"
@@ -9,6 +9,7 @@ export interface Feature {
9
9
  details: string
10
10
  link?: string
11
11
  linkText?: string
12
+ rel?: string
12
13
  }
13
14
 
14
15
  const props = defineProps<{
@@ -48,6 +49,7 @@ const grid = computed(() => {
48
49
  :details="feature.details"
49
50
  :link="feature.link"
50
51
  :link-text="feature.linkText"
52
+ :rel="feature.rel"
51
53
  />
52
54
  </div>
53
55
  </div>
@@ -11,7 +11,7 @@ const props = defineProps<{
11
11
  rel?: string
12
12
  }>()
13
13
 
14
- const tag = computed(() => props.tag ?? props.href ? 'a' : 'span')
14
+ const tag = computed(() => props.tag ?? (props.href ? 'a' : 'span'))
15
15
  const isExternal = computed(() => props.href && EXTERNAL_URL_RE.test(props.href))
16
16
  </script>
17
17
 
@@ -25,8 +25,8 @@ const isExternal = computed(() => props.href && EXTERNAL_URL_RE.test(props.href)
25
25
  'no-icon': noIcon
26
26
  }"
27
27
  :href="href ? normalizeLink(href) : undefined"
28
- :target="target || (isExternal ? '_blank' : undefined)"
29
- :rel="rel || (isExternal ? 'noreferrer' : undefined)"
28
+ :target="target ?? (isExternal ? '_blank' : undefined)"
29
+ :rel="rel ?? (isExternal ? 'noreferrer' : undefined)"
30
30
  >
31
31
  <slot />
32
32
  </component>
@@ -20,7 +20,7 @@ function normalizeLink(link, addPath, path, addExt) {
20
20
  return addPath
21
21
  ? link.replace(/\/$/, '') +
22
22
  ensureStartingSlash(path
23
- .replace(/(^|\/)?index.md$/, '$1')
23
+ .replace(/(^|\/)index\.md$/, '$1')
24
24
  .replace(/\.md$/, addExt ? '.html' : ''))
25
25
  : link;
26
26
  }
@@ -11,16 +11,7 @@
11
11
  background-color: var(--vp-code-tab-bg);
12
12
  overflow-x: auto;
13
13
  overflow-y: hidden;
14
- }
15
-
16
- .vp-code-group .tabs::after {
17
- position: absolute;
18
- right: 0;
19
- bottom: 0;
20
- left: 0;
21
- height: 1px;
22
- background-color: var(--vp-code-tab-divider);
23
- content: '';
14
+ box-shadow: inset 0 -1px var(--vp-code-tab-divider);
24
15
  }
25
16
 
26
17
  @media (min-width: 640px) {
@@ -36,9 +36,10 @@
36
36
  }
37
37
 
38
38
  .vp-doc .header-anchor {
39
- float: left;
39
+ position: absolute;
40
+ top: 0;
41
+ left: 0;
40
42
  margin-left: -0.87em;
41
- padding-right: 0.23em;
42
43
  font-weight: 500;
43
44
  user-select: none;
44
45
  opacity: 0;
@@ -74,6 +75,10 @@
74
75
  }
75
76
  }
76
77
 
78
+ .vp-doc h2 .header-anchor {
79
+ top: 24px;
80
+ }
81
+
77
82
  /**
78
83
  * Paragraph and inline elements
79
84
  * -------------------------------------------------------------------------- */
package/dist/node/cli.js CHANGED
@@ -1,18 +1,13 @@
1
- import { o as getDefaultExportFromCjs, p as c, q as clearCache, k as build, s as serve, l as init, j as createServer } from './serve-98a6c925.js';
1
+ import { o as getDefaultExportFromCjs, p as c, q as clearCache, k as build, s as serve, l as init, j as createServer } from './serve-bbb8fb22.js';
2
2
  import { createLogger } from 'vite';
3
3
  import 'url';
4
4
  import 'path';
5
5
  import 'dns';
6
6
  import 'crypto';
7
7
  import 'module';
8
- import 'node:process';
9
- import 'assert';
10
- import 'events';
11
- import 'node:readline';
12
- import 'stream';
13
- import 'buffer';
14
8
  import 'node:path';
15
9
  import 'node:url';
10
+ import 'node:process';
16
11
  import 'node:fs';
17
12
  import 'util';
18
13
  import 'fs';
@@ -21,12 +16,19 @@ import 'node:events';
21
16
  import 'node:stream';
22
17
  import 'node:string_decoder';
23
18
  import 'os';
19
+ import 'assert';
20
+ import 'events';
21
+ import 'node:readline';
22
+ import 'stream';
23
+ import 'buffer';
24
24
  import 'shiki';
25
25
  import 'child_process';
26
26
  import 'minisearch';
27
+ import 'readline';
28
+ import 'string_decoder';
29
+ import 'zlib';
27
30
  import 'tty';
28
31
  import 'net';
29
- import 'zlib';
30
32
  import 'http';
31
33
  import 'querystring';
32
34
  import 'node:tty';
@@ -296,7 +298,7 @@ var minimist = function (args, opts) {
296
298
 
297
299
  var minimist$1 = /*@__PURE__*/getDefaultExportFromCjs(minimist);
298
300
 
299
- var version = "1.0.0-beta.6";
301
+ var version = "1.0.0-beta.7";
300
302
 
301
303
  function bindShortcuts(server, createDevServer) {
302
304
  if (!server.httpServer || !process.stdin.isTTY || process.env.CI) {
@@ -1,13 +1,165 @@
1
+ /// <reference types="node" />
1
2
  import * as vite from 'vite';
2
3
  import { Logger, UserConfig as UserConfig$1, ConfigEnv, ServerOptions, BuildOptions } from 'vite';
3
4
  export { loadEnv } from 'vite';
4
5
  import { Header, Awaitable, SiteData, PageData, HeadConfig, LocaleSpecificConfig, LocaleConfig, SSGContext, DefaultTheme } from '../../types/shared.js';
5
6
  export { DefaultTheme, HeadConfig, Header, SiteData } from '../../types/shared.js';
6
- import { IThemeRegistration, ILanguageRegistration } from 'shiki';
7
7
  import { Options } from '@vitejs/plugin-vue';
8
+ import { TransformOptions } from 'stream';
9
+ import { IThemeRegistration, ILanguageRegistration } from 'shiki';
8
10
  import { IncomingMessage, ServerResponse } from 'http';
9
11
  import { Server, ListenOptions } from 'net';
10
12
 
13
+ /**
14
+ * How frequently the page is likely to change. This value provides general
15
+ * information to search engines and may not correlate exactly to how often they crawl the page. Please note that the
16
+ * value of this tag is considered a hint and not a command. See
17
+ * <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable
18
+ * values
19
+ */
20
+ declare enum EnumChangefreq {
21
+ DAILY = "daily",
22
+ MONTHLY = "monthly",
23
+ ALWAYS = "always",
24
+ HOURLY = "hourly",
25
+ WEEKLY = "weekly",
26
+ YEARLY = "yearly",
27
+ NEVER = "never"
28
+ }
29
+ /**
30
+ * https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190
31
+ */
32
+ interface NewsItem {
33
+ access?: 'Registration' | 'Subscription';
34
+ publication: {
35
+ name: string;
36
+ /**
37
+ * The `<language>` is the language of your publication. Use an ISO 639
38
+ * language code (2 or 3 letters).
39
+ */
40
+ language: string;
41
+ };
42
+ /**
43
+ * @example 'PressRelease, Blog'
44
+ */
45
+ genres?: string;
46
+ /**
47
+ * Article publication date in W3C format, using either the "complete date" (YYYY-MM-DD) format or the "complete date
48
+ * plus hours, minutes, and seconds"
49
+ */
50
+ publication_date: string;
51
+ /**
52
+ * The title of the news article
53
+ * @example 'Companies A, B in Merger Talks'
54
+ */
55
+ title: string;
56
+ /**
57
+ * @example 'business, merger, acquisition'
58
+ */
59
+ keywords?: string;
60
+ /**
61
+ * @example 'NASDAQ:A, NASDAQ:B'
62
+ */
63
+ stock_tickers?: string;
64
+ }
65
+ /**
66
+ * Sitemap Image
67
+ * https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190
68
+ */
69
+ interface Img {
70
+ /**
71
+ * The URL of the image
72
+ * @example 'https://example.com/image.jpg'
73
+ */
74
+ url: string;
75
+ /**
76
+ * The caption of the image
77
+ * @example 'Thanksgiving dinner'
78
+ */
79
+ caption?: string;
80
+ /**
81
+ * The title of the image
82
+ * @example 'Star Wars EP IV'
83
+ */
84
+ title?: string;
85
+ /**
86
+ * The geographic location of the image.
87
+ * @example 'Limerick, Ireland'
88
+ */
89
+ geoLocation?: string;
90
+ /**
91
+ * A URL to the license of the image.
92
+ * @example 'https://example.com/license.txt'
93
+ */
94
+ license?: string;
95
+ }
96
+ /**
97
+ * https://support.google.com/webmasters/answer/189077
98
+ */
99
+ interface LinkItem {
100
+ /**
101
+ * @example 'en'
102
+ */
103
+ lang: string;
104
+ /**
105
+ * @example 'en-us'
106
+ */
107
+ hreflang?: string;
108
+ url: string;
109
+ }
110
+ /**
111
+ * How to handle errors in passed in urls
112
+ */
113
+ declare enum ErrorLevel {
114
+ /**
115
+ * Validation will be skipped and nothing logged or thrown.
116
+ */
117
+ SILENT = "silent",
118
+ /**
119
+ * If an invalid value is encountered, a console.warn will be called with details
120
+ */
121
+ WARN = "warn",
122
+ /**
123
+ * An Error will be thrown on encountering invalid data.
124
+ */
125
+ THROW = "throw"
126
+ }
127
+ declare type ErrorHandler$1 = (error: Error, level: ErrorLevel) => void;
128
+
129
+ interface NSArgs {
130
+ news: boolean;
131
+ video: boolean;
132
+ xhtml: boolean;
133
+ image: boolean;
134
+ custom?: string[];
135
+ }
136
+ interface SitemapStreamOptions extends TransformOptions {
137
+ hostname?: string;
138
+ level?: ErrorLevel;
139
+ lastmodDateOnly?: boolean;
140
+ xmlns?: NSArgs;
141
+ xslUrl?: string;
142
+ errorHandler?: ErrorHandler$1;
143
+ }
144
+
145
+ interface SitemapItem {
146
+ lastmod?: string | number | Date;
147
+ changefreq?: `${EnumChangefreq}`;
148
+ fullPrecisionPriority?: boolean;
149
+ priority?: number;
150
+ news?: NewsItem;
151
+ expires?: string;
152
+ androidLink?: string;
153
+ ampLink?: string;
154
+ url: string;
155
+ video?: any;
156
+ img?: string | Img | (string | Img)[];
157
+ links?: LinkItem[];
158
+ lastmodfile?: string | Buffer | URL;
159
+ lastmodISO?: string;
160
+ lastmodrealtime?: boolean;
161
+ }
162
+
11
163
  // Type definitions for linkify-it 3.0.2
12
164
  // Project: https://github.com/markdown-it/linkify-it
13
165
  // Definitions by: Lindsey Smith <https://github.com/praxxis>
@@ -1881,6 +2033,13 @@ interface UserConfig<ThemeConfig = any> extends LocaleSpecificConfig<ThemeConfig
1881
2033
  * source -> destination
1882
2034
  */
1883
2035
  rewrites?: Record<string, string>;
2036
+ /**
2037
+ * @experimental
2038
+ */
2039
+ sitemap?: SitemapStreamOptions & {
2040
+ hostname: string;
2041
+ transformItems?: (items: SitemapItem[]) => Awaitable<SitemapItem[]>;
2042
+ };
1884
2043
  /**
1885
2044
  * Build end hook: called when SSG finish.
1886
2045
  * @param siteConfig The resolved configuration.
@@ -1907,7 +2066,7 @@ interface UserConfig<ThemeConfig = any> extends LocaleSpecificConfig<ThemeConfig
1907
2066
  [key: string]: any;
1908
2067
  } | void>;
1909
2068
  }
1910
- interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'metaChunk' | 'lastUpdated' | 'ignoreDeadLinks' | 'cleanUrls' | 'useWebFonts' | 'postRender' | 'buildEnd' | 'transformHead' | 'transformHtml' | 'transformPageData'> {
2069
+ interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa' | 'metaChunk' | 'lastUpdated' | 'ignoreDeadLinks' | 'cleanUrls' | 'useWebFonts' | 'postRender' | 'buildEnd' | 'transformHead' | 'transformHtml' | 'transformPageData' | 'sitemap'> {
1911
2070
  root: string;
1912
2071
  srcDir: string;
1913
2072
  site: SiteData<ThemeConfig>;
@@ -2078,19 +2237,34 @@ declare function scaffold({ root, title, description, theme, useTs, injectNpmScr
2078
2237
  interface ContentOptions<T = ContentData[]> {
2079
2238
  /**
2080
2239
  * Include src?
2081
- * default: false
2240
+ * @default false
2082
2241
  */
2083
2242
  includeSrc?: boolean;
2084
2243
  /**
2085
2244
  * Render src to HTML and include in data?
2086
- * default: false
2245
+ * @default false
2087
2246
  */
2088
2247
  render?: boolean;
2089
2248
  /**
2090
- * Whether to parse and include excerpt (rendered as HTML)
2091
- * default: false
2249
+ * If `boolean`, whether to parse and include excerpt? (rendered as HTML)
2250
+ *
2251
+ * If `function`, control how the excerpt is extracted from the content.
2252
+ *
2253
+ * If `string`, define a custom separator to be used for extracting the
2254
+ * excerpt. Default separator is `---` if `excerpt` is `true`.
2255
+ *
2256
+ * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt
2257
+ * @see https://github.com/jonschlinkert/gray-matter#optionsexcerpt_separator
2258
+ *
2259
+ * @default false
2092
2260
  */
2093
- excerpt?: boolean;
2261
+ excerpt?: boolean | ((file: {
2262
+ data: {
2263
+ [key: string]: any;
2264
+ };
2265
+ content: string;
2266
+ excerpt?: string;
2267
+ }, options?: any) => void) | string;
2094
2268
  /**
2095
2269
  * Transform the data. Note the data will be inlined as JSON in the client
2096
2270
  * bundle if imported from components or markdown files.
@@ -1,19 +1,14 @@
1
- import { g as glob, c as createMarkdownRenderer, f as fs, m as matter } from './serve-98a6c925.js';
2
- export { S as ScaffoldThemeType, k as build, j as createServer, a as defineConfig, b as defineConfigWithTheme, d as defineLoader, l as init, r as resolveConfig, i as resolvePages, h as resolveSiteData, e as resolveUserConfig, n as scaffold, s as serve } from './serve-98a6c925.js';
1
+ import { g as glob, c as createMarkdownRenderer, f as fs, m as matter } from './serve-bbb8fb22.js';
2
+ export { S as ScaffoldThemeType, k as build, j as createServer, a as defineConfig, b as defineConfigWithTheme, d as defineLoader, l as init, r as resolveConfig, i as resolvePages, h as resolveSiteData, e as resolveUserConfig, n as scaffold, s as serve } from './serve-bbb8fb22.js';
3
3
  import path from 'path';
4
4
  import { normalizePath } from 'vite';
5
5
  export { loadEnv } from 'vite';
6
6
  import 'dns';
7
7
  import 'crypto';
8
8
  import 'module';
9
- import 'node:process';
10
- import 'assert';
11
- import 'events';
12
- import 'node:readline';
13
- import 'stream';
14
- import 'buffer';
15
9
  import 'node:path';
16
10
  import 'node:url';
11
+ import 'node:process';
17
12
  import 'node:fs';
18
13
  import 'util';
19
14
  import 'url';
@@ -23,12 +18,19 @@ import 'node:events';
23
18
  import 'node:stream';
24
19
  import 'node:string_decoder';
25
20
  import 'os';
21
+ import 'assert';
22
+ import 'events';
23
+ import 'node:readline';
24
+ import 'stream';
25
+ import 'buffer';
26
26
  import 'shiki';
27
27
  import 'child_process';
28
28
  import 'minisearch';
29
+ import 'readline';
30
+ import 'string_decoder';
31
+ import 'zlib';
29
32
  import 'tty';
30
33
  import 'net';
31
- import 'zlib';
32
34
  import 'http';
33
35
  import 'querystring';
34
36
  import 'node:tty';
@@ -76,13 +78,12 @@ function createContentLoader(pattern, {
76
78
  raw.push(cached.data);
77
79
  } else {
78
80
  const src = fs.readFileSync(file, "utf-8");
79
- const { data: frontmatter, excerpt } = matter(src, {
80
- excerpt: true
81
- });
82
- const url = "/" + normalizePath(path.relative(config.root, file)).replace(
83
- /\.md$/,
84
- config.cleanUrls ? "" : ".html"
81
+ const { data: frontmatter, excerpt } = matter(
82
+ src,
83
+ // @ts-expect-error gray-matter types are wrong
84
+ typeof renderExcerpt === "string" ? { excerpt_separator: renderExcerpt } : { excerpt: renderExcerpt }
85
85
  );
86
+ const url = "/" + normalizePath(path.relative(config.srcDir, file)).replace(/(^|\/)index\.md$/, "$1").replace(/\.md$/, config.cleanUrls ? "" : ".html");
86
87
  const html = render ? md.render(src) : void 0;
87
88
  const renderedExcerpt = renderExcerpt ? excerpt && md.render(excerpt) : void 0;
88
89
  const data = {