vitepress 0.20.6 → 0.20.10
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/client.d.ts
ADDED
package/dist/node/cli.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare interface ServeOptions {
|
|
|
83
83
|
port?: number;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export declare interface SiteConfig<ThemeConfig = any> {
|
|
86
|
+
export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa'> {
|
|
87
87
|
root: string;
|
|
88
88
|
srcDir: string;
|
|
89
89
|
site: SiteData<ThemeConfig>;
|
|
@@ -93,10 +93,6 @@ export declare interface SiteConfig<ThemeConfig = any> {
|
|
|
93
93
|
tempDir: string;
|
|
94
94
|
alias: AliasOptions;
|
|
95
95
|
pages: string[];
|
|
96
|
-
markdown: MarkdownOptions | undefined;
|
|
97
|
-
vue: Options | undefined;
|
|
98
|
-
vite: UserConfig_2 | undefined;
|
|
99
|
-
mpa: boolean;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
export declare interface SiteData<ThemeConfig = any> {
|
|
@@ -153,6 +149,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
153
149
|
vite?: UserConfig_2;
|
|
154
150
|
srcDir?: string;
|
|
155
151
|
srcExclude?: string[];
|
|
152
|
+
shouldPreload?: (link: string, page: string) => boolean;
|
|
156
153
|
/**
|
|
157
154
|
* Enable MPA / zero-JS mode
|
|
158
155
|
* @experimental
|
package/dist/node/index.js
CHANGED
|
@@ -13372,6 +13372,7 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13372
13372
|
alias: resolveAliases(themeDir),
|
|
13373
13373
|
vue: userConfig.vue,
|
|
13374
13374
|
vite: userConfig.vite,
|
|
13375
|
+
shouldPreload: userConfig.shouldPreload,
|
|
13375
13376
|
mpa: !!userConfig.mpa
|
|
13376
13377
|
};
|
|
13377
13378
|
return config;
|
|
@@ -36464,9 +36465,11 @@ const staticDataPlugin = {
|
|
|
36464
36465
|
({ pattern, loader } = existing);
|
|
36465
36466
|
} else {
|
|
36466
36467
|
const loaderModule = (_a = await vite.loadConfigFromFile({}, id)) == null ? void 0 : _a.config;
|
|
36467
|
-
pattern = loaderModule.watch;
|
|
36468
|
-
if (pattern
|
|
36469
|
-
pattern = pattern.
|
|
36468
|
+
pattern = typeof loaderModule.watch === "string" ? [loaderModule.watch] : loaderModule.watch;
|
|
36469
|
+
if (pattern) {
|
|
36470
|
+
pattern = pattern.map((p) => {
|
|
36471
|
+
return p.startsWith("./") ? p.slice(2) : p;
|
|
36472
|
+
});
|
|
36470
36473
|
}
|
|
36471
36474
|
loader = loaderModule.load;
|
|
36472
36475
|
}
|
|
@@ -36485,7 +36488,7 @@ const staticDataPlugin = {
|
|
|
36485
36488
|
const { base, pattern } = idToLoaderModulesMap[id];
|
|
36486
36489
|
server._globImporters[id] = {
|
|
36487
36490
|
module: server.moduleGraph.getModuleById(id),
|
|
36488
|
-
importGlobs:
|
|
36491
|
+
importGlobs: pattern == null ? void 0 : pattern.map((pattern2) => ({ base, pattern: pattern2 }))
|
|
36489
36492
|
};
|
|
36490
36493
|
}
|
|
36491
36494
|
return null;
|
|
@@ -40039,13 +40042,25 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40039
40042
|
const pageClientJsFileName = `assets/${pageName}.${pageHash}.lean.js`;
|
|
40040
40043
|
const { __pageData } = require(path__default["default"].join(config.tempDir, pageServerJsFileName));
|
|
40041
40044
|
const pageData = JSON.parse(__pageData);
|
|
40042
|
-
|
|
40043
|
-
...
|
|
40044
|
-
|
|
40045
|
-
|
|
40046
|
-
|
|
40045
|
+
let preloadLinks = config.mpa ? appChunk ? [appChunk.fileName] : [] : result && appChunk ? [
|
|
40046
|
+
...new Set([
|
|
40047
|
+
...resolvePageImports(config, page, result, appChunk),
|
|
40048
|
+
pageClientJsFileName,
|
|
40049
|
+
appChunk.fileName
|
|
40050
|
+
])
|
|
40051
|
+
] : [];
|
|
40052
|
+
let prefetchLinks = [];
|
|
40053
|
+
const { shouldPreload } = config;
|
|
40054
|
+
if (shouldPreload) {
|
|
40055
|
+
prefetchLinks = preloadLinks.filter((link) => !shouldPreload(link, page));
|
|
40056
|
+
preloadLinks = preloadLinks.filter((link) => shouldPreload(link, page));
|
|
40057
|
+
}
|
|
40058
|
+
const preloadLinksString = preloadLinks.map((file) => {
|
|
40047
40059
|
return `<link rel="modulepreload" href="${siteData.base}${file}">`;
|
|
40048
40060
|
}).join("\n ");
|
|
40061
|
+
const prefetchLinkString = prefetchLinks.map((file) => {
|
|
40062
|
+
return `<link rel="prefetch" href="${siteData.base}${file}">`;
|
|
40063
|
+
}).join("\n ");
|
|
40049
40064
|
const stylesheetLink = cssChunk ? `<link rel="stylesheet" href="${siteData.base}${cssChunk.fileName}">` : "";
|
|
40050
40065
|
const title = pageData.title && pageData.title !== "Home" ? `${pageData.title} | ${siteData.title}` : siteData.title;
|
|
40051
40066
|
const head = addSocialTags(title, ...siteData.head, ...filterOutHeadDescription(pageData.frontmatter.head));
|
|
@@ -40070,8 +40085,9 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40070
40085
|
<title>${title}</title>
|
|
40071
40086
|
<meta name="description" content="${pageData.description || siteData.description}">
|
|
40072
40087
|
${stylesheetLink}
|
|
40073
|
-
${
|
|
40074
|
-
${
|
|
40088
|
+
${preloadLinksString}
|
|
40089
|
+
${prefetchLinkString}
|
|
40090
|
+
${await renderHead(head)}
|
|
40075
40091
|
</head>
|
|
40076
40092
|
<body>
|
|
40077
40093
|
<div id="app">${content}</div>
|
|
@@ -40084,25 +40100,30 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40084
40100
|
await lib$1.ensureDir(path__default["default"].dirname(htmlFileName));
|
|
40085
40101
|
await lib$1.writeFile(htmlFileName, html);
|
|
40086
40102
|
}
|
|
40087
|
-
function resolvePageImports(config, page, result,
|
|
40103
|
+
function resolvePageImports(config, page, result, appChunk) {
|
|
40088
40104
|
const srcPath = vite.normalizePath(lib$1.realpathSync(path__default["default"].resolve(config.srcDir, page)));
|
|
40089
40105
|
const pageChunk = result.output.find((chunk) => chunk.type === "chunk" && chunk.facadeModuleId === srcPath);
|
|
40090
|
-
return
|
|
40091
|
-
...
|
|
40092
|
-
...
|
|
40106
|
+
return [
|
|
40107
|
+
...appChunk.imports,
|
|
40108
|
+
...appChunk.dynamicImports,
|
|
40093
40109
|
...pageChunk.imports,
|
|
40094
40110
|
...pageChunk.dynamicImports
|
|
40095
|
-
]
|
|
40111
|
+
];
|
|
40096
40112
|
}
|
|
40097
40113
|
function renderHead(head) {
|
|
40098
|
-
return head.map(([tag, attrs = {}, innerHTML = ""]) => {
|
|
40114
|
+
return Promise.all(head.map(async ([tag, attrs = {}, innerHTML = ""]) => {
|
|
40099
40115
|
const openTag = `<${tag}${renderAttrs(attrs)}>`;
|
|
40100
40116
|
if (tag !== "link" && tag !== "meta") {
|
|
40117
|
+
if (tag === "script") {
|
|
40118
|
+
innerHTML = (await vite.transformWithEsbuild(innerHTML, "inline-script.js", {
|
|
40119
|
+
minify: true
|
|
40120
|
+
})).code.trim();
|
|
40121
|
+
}
|
|
40101
40122
|
return `${openTag}${innerHTML}</${tag}>`;
|
|
40102
40123
|
} else {
|
|
40103
40124
|
return openTag;
|
|
40104
40125
|
}
|
|
40105
|
-
}).join("\n
|
|
40126
|
+
})).then((tags) => tags.join("\n "));
|
|
40106
40127
|
}
|
|
40107
40128
|
function renderAttrs(attrs) {
|
|
40108
40129
|
return Object.keys(attrs).map((key) => {
|
package/dist/vitepress.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare interface ServeOptions {
|
|
|
83
83
|
port?: number;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export declare interface SiteConfig<ThemeConfig = any> {
|
|
86
|
+
export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa'> {
|
|
87
87
|
root: string;
|
|
88
88
|
srcDir: string;
|
|
89
89
|
site: SiteData<ThemeConfig>;
|
|
@@ -93,10 +93,6 @@ export declare interface SiteConfig<ThemeConfig = any> {
|
|
|
93
93
|
tempDir: string;
|
|
94
94
|
alias: AliasOptions;
|
|
95
95
|
pages: string[];
|
|
96
|
-
markdown: MarkdownOptions | undefined;
|
|
97
|
-
vue: Options | undefined;
|
|
98
|
-
vite: UserConfig_2 | undefined;
|
|
99
|
-
mpa: boolean;
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
export declare interface SiteData<ThemeConfig = any> {
|
|
@@ -153,6 +149,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
153
149
|
vite?: UserConfig_2;
|
|
154
150
|
srcDir?: string;
|
|
155
151
|
srcExclude?: string[];
|
|
152
|
+
shouldPreload?: (link: string, page: string) => boolean;
|
|
156
153
|
/**
|
|
157
154
|
* Enable MPA / zero-JS mode
|
|
158
155
|
* @experimental
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.10",
|
|
4
4
|
"description": "Vite & Vue powered static site generator",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
12
12
|
"dist",
|
|
13
|
-
"types"
|
|
13
|
+
"types",
|
|
14
|
+
"client.d.ts"
|
|
14
15
|
],
|
|
15
16
|
"engines": {
|
|
16
17
|
"node": ">=12.0.0"
|
|
@@ -130,5 +131,6 @@
|
|
|
130
131
|
"docs-build": "npm run build && node ./bin/vitepress build docs",
|
|
131
132
|
"docs-serve": "node ./bin/vitepress serve docs",
|
|
132
133
|
"ci-docs": "run-s build docs-build"
|
|
133
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"readme": "# (WIP) VitePress 📝💨\n\n[](https://github.com/vuejs/vitepress/actions)\n[](https://www.npmjs.com/package/vitepress)\n\n---\n\nVitePress is [VuePress](http://vuepress.vuejs.org/)' spiritual successor, built on top of [vite](https://github.com/vuejs/vite).\n\n## Documentation\n\nTo check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).\n\n## Changelog\n\nDetailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/master/CHANGELOG.md).\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](./.github/contributing.md) before making a pull request.\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2019-present, Yuxi (Evan) You\n"
|
|
134
136
|
}
|