valaxy 1.3.1 → 1.3.3
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.
|
@@ -58,6 +58,7 @@ export function useValaxyApp() {
|
|
|
58
58
|
// Personal Website or Blog. url is the author's link, or the site when that link is unset.
|
|
59
59
|
definePerson({
|
|
60
60
|
name: $t(siteConfig.value.author.name),
|
|
61
|
+
...(author.email ? { email: author.email } : {}),
|
|
61
62
|
...(personUrl ? { url: personUrl } : {}),
|
|
62
63
|
image: $t(siteConfig.value.author.avatar),
|
|
63
64
|
sameAs: resolveSocialSameAs(siteConfig.value.url, siteConfig.value.social, siteConfig.value.feed?.name),
|
package/client/config.ts
CHANGED
package/dist/node/cli/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import 'node:path';
|
|
|
2
2
|
import 'node:process';
|
|
3
3
|
import 'yargs';
|
|
4
4
|
import 'yargs/helpers';
|
|
5
|
-
export { c as createCli, s as desktopRuntimeVersion, u as execBuild, O as registerDevCommand, a1 as run, a3 as startValaxyDev } from '../../shared/valaxy.
|
|
5
|
+
export { c as createCli, s as desktopRuntimeVersion, u as execBuild, O as registerDevCommand, a1 as run, a3 as startValaxyDev } from '../../shared/valaxy.aOnvqwjo.mjs';
|
|
6
6
|
import 'node:os';
|
|
7
7
|
import '@11ty/gray-matter';
|
|
8
8
|
import 'consola';
|
|
@@ -62,8 +62,9 @@ import 'jiti';
|
|
|
62
62
|
import 'unocss';
|
|
63
63
|
import 'html-to-text';
|
|
64
64
|
import 'vue-router/vite';
|
|
65
|
-
import 'vite-ssg-sitemap';
|
|
66
65
|
import '@unhead/vue/server';
|
|
66
|
+
import 'htmlparser2';
|
|
67
|
+
import 'escape-html';
|
|
67
68
|
import 'vue-router/unplugin';
|
|
68
69
|
import 'node:child_process';
|
|
69
70
|
import '@clack/prompts';
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, S as StateManager, V as ViteValaxyPlugins, b as build, c as createCli, a as createContentService, d as createMemoryReleasePlugin, e as createServer, f as createValaxyNode, g as createValaxyPlugin, h as customElements, i as defaultSiteConfig, j as defaultValaxyConfig, k as defaultViteConfig, l as defineAddon, m as defineConfig, n as defineSiteConfig, o as defineTheme, p as defineValaxyAddon, q as defineValaxyConfig, r as defineValaxyTheme, s as desktopRuntimeVersion, t as encryptContent, u as execBuild, v as generateClientRedirects, w as getGitTimestamp, x as getIndexHtml, y as getServerInfoText, z as isExternal, B as isInstalledGlobally, C as isKatexEnabled, D as isKatexPluginNeeded, F as isMathJaxEnabled, H as isPath, I as loadAllContent, J as loadConfigFromFile, K as mergeValaxyConfig, L as mergeViteConfigs, M as postProcessForSSG, N as processValaxyOptions, O as registerDevCommand, Q as resolveAddonsConfig, R as resolveImportPath, T as resolveImportUrl, U as resolveOptions, W as resolveSiteConfig, X as resolveSiteConfigFromRoot, Y as resolveThemeConfigFromRoot, Z as resolveThemeValaxyConfig, _ as resolveUserThemeConfig, $ as resolveValaxyConfig, a0 as resolveValaxyConfigFromRoot, a1 as run, a2 as ssgBuild, a3 as startValaxyDev, a4 as toAtFS, a5 as transformObject, a6 as version } from '../shared/valaxy.
|
|
1
|
+
export { A as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, S as StateManager, V as ViteValaxyPlugins, b as build, c as createCli, a as createContentService, d as createMemoryReleasePlugin, e as createServer, f as createValaxyNode, g as createValaxyPlugin, h as customElements, i as defaultSiteConfig, j as defaultValaxyConfig, k as defaultViteConfig, l as defineAddon, m as defineConfig, n as defineSiteConfig, o as defineTheme, p as defineValaxyAddon, q as defineValaxyConfig, r as defineValaxyTheme, s as desktopRuntimeVersion, t as encryptContent, u as execBuild, v as generateClientRedirects, w as getGitTimestamp, x as getIndexHtml, y as getServerInfoText, z as isExternal, B as isInstalledGlobally, C as isKatexEnabled, D as isKatexPluginNeeded, F as isMathJaxEnabled, H as isPath, I as loadAllContent, J as loadConfigFromFile, K as mergeValaxyConfig, L as mergeViteConfigs, M as postProcessForSSG, N as processValaxyOptions, O as registerDevCommand, Q as resolveAddonsConfig, R as resolveImportPath, T as resolveImportUrl, U as resolveOptions, W as resolveSiteConfig, X as resolveSiteConfigFromRoot, Y as resolveThemeConfigFromRoot, Z as resolveThemeValaxyConfig, _ as resolveUserThemeConfig, $ as resolveValaxyConfig, a0 as resolveValaxyConfigFromRoot, a1 as run, a2 as ssgBuild, a3 as startValaxyDev, a4 as toAtFS, a5 as transformObject, a6 as version } from '../shared/valaxy.aOnvqwjo.mjs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'fs-extra';
|
|
@@ -62,8 +62,9 @@ import 'jiti';
|
|
|
62
62
|
import 'unocss';
|
|
63
63
|
import 'html-to-text';
|
|
64
64
|
import 'vue-router/vite';
|
|
65
|
-
import 'vite-ssg-sitemap';
|
|
66
65
|
import '@unhead/vue/server';
|
|
66
|
+
import 'htmlparser2';
|
|
67
|
+
import 'escape-html';
|
|
67
68
|
import 'vue-router/unplugin';
|
|
68
69
|
import 'node:child_process';
|
|
69
70
|
import '@clack/prompts';
|
|
@@ -62,8 +62,9 @@ import { createJiti } from 'jiti';
|
|
|
62
62
|
import { transformerDirectives, transformerVariantGroup, presetWind4, presetAttributify, presetIcons, presetTypography } from 'unocss';
|
|
63
63
|
import { convert } from 'html-to-text';
|
|
64
64
|
import VueRouter from 'vue-router/vite';
|
|
65
|
-
import generateSitemap from 'vite-ssg-sitemap';
|
|
66
65
|
import { renderSSRHead } from '@unhead/vue/server';
|
|
66
|
+
import { Parser } from 'htmlparser2';
|
|
67
|
+
import escapeHtml from 'escape-html';
|
|
67
68
|
import { createRoutesContext, resolveOptions as resolveOptions$3 } from 'vue-router/unplugin';
|
|
68
69
|
import { execSync, exec } from 'node:child_process';
|
|
69
70
|
import { intro, confirm, isCancel, cancel, select, outro } from '@clack/prompts';
|
|
@@ -72,7 +73,7 @@ import * as readline from 'node:readline';
|
|
|
72
73
|
import qrcode from 'qrcode';
|
|
73
74
|
import ejs from 'ejs';
|
|
74
75
|
|
|
75
|
-
const version = "1.3.
|
|
76
|
+
const version = "1.3.3";
|
|
76
77
|
|
|
77
78
|
const GLOBAL_STATE = {
|
|
78
79
|
valaxyApp: void 0,
|
|
@@ -238,14 +239,8 @@ function mergePageExcludes(publishing, userExclude) {
|
|
|
238
239
|
return userExclude(defaults);
|
|
239
240
|
return [...defaults, ...normalizeExcludeGlobs(userExclude)];
|
|
240
241
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
-
for (const route of routes) {
|
|
244
|
-
const path = route.length > 1 && route.endsWith("/") ? route.slice(0, -1) : route;
|
|
245
|
-
if (path === "/404" || path.endsWith("/404"))
|
|
246
|
-
paths.add(path);
|
|
247
|
-
}
|
|
248
|
-
return [...paths];
|
|
242
|
+
function isNotFoundPagePath(path) {
|
|
243
|
+
return /\/404(?:\.html|\/(?:index\.html)?)?$/.test(path);
|
|
249
244
|
}
|
|
250
245
|
|
|
251
246
|
function publicAuthor(author) {
|
|
@@ -7548,11 +7543,25 @@ const templateConfig = {
|
|
|
7548
7543
|
redirect: redirect.to
|
|
7549
7544
|
};
|
|
7550
7545
|
});
|
|
7551
|
-
|
|
7546
|
+
const redirects = {
|
|
7552
7547
|
useVueRouter: isProd() ? options.config.siteConfig.redirects.useVueRouter : true,
|
|
7553
7548
|
redirectRoutes: routes
|
|
7554
7549
|
};
|
|
7555
|
-
|
|
7550
|
+
const { devtools, siteConfig, theme, themeConfig, runtimeConfig } = options.config;
|
|
7551
|
+
const config = options.mode === "dev" ? { ...options.config, runtimeConfig: { ...runtimeConfig, redirects } } : {
|
|
7552
|
+
devtools,
|
|
7553
|
+
siteConfig,
|
|
7554
|
+
theme,
|
|
7555
|
+
themeConfig,
|
|
7556
|
+
runtimeConfig: {
|
|
7557
|
+
redirects,
|
|
7558
|
+
addons: Object.fromEntries(Object.entries(runtimeConfig.addons).map(([key, addon]) => {
|
|
7559
|
+
const { name, enable, global, props, options: options2 } = addon;
|
|
7560
|
+
return [key, { name, enable, global, props, options: options2 }];
|
|
7561
|
+
}))
|
|
7562
|
+
}
|
|
7563
|
+
};
|
|
7564
|
+
return `export default ${JSON.stringify(JSON.stringify(config))}`;
|
|
7556
7565
|
}
|
|
7557
7566
|
};
|
|
7558
7567
|
|
|
@@ -7676,8 +7685,7 @@ async function createValaxyPlugin(options, serverOptions = {}, state = Valaxy.st
|
|
|
7676
7685
|
}
|
|
7677
7686
|
if (id === "/@valaxyjs/context") {
|
|
7678
7687
|
return `export default ${JSON.stringify(JSON.stringify({
|
|
7679
|
-
userRoot: options.userRoot
|
|
7680
|
-
// clientRoot: options.clientRoot,
|
|
7688
|
+
userRoot: options.mode === "dev" ? options.userRoot : ""
|
|
7681
7689
|
}))}`;
|
|
7682
7690
|
}
|
|
7683
7691
|
if (id === "/@valaxyjs/AppVue")
|
|
@@ -8357,7 +8365,7 @@ async function renderPage(opts) {
|
|
|
8357
8365
|
html = html.replace(/<html[^>]*>/, `<html ${headPayload.htmlAttrs}>`);
|
|
8358
8366
|
if (headPayload.bodyAttrs)
|
|
8359
8367
|
html = html.replace(/<body[^>]*>/, `<body ${headPayload.bodyAttrs}>`);
|
|
8360
|
-
html = html.replace("</head>", `${preloadLinks}${headPayload.headTags}
|
|
8368
|
+
html = html.replace("</head>", () => `${preloadLinks}${headPayload.headTags}
|
|
8361
8369
|
</head>`).replace(
|
|
8362
8370
|
'<div id="app"></div>',
|
|
8363
8371
|
`${headPayload.bodyTagsOpen || ""}<div id="app">${result.html}</div>${stateScript}${headPayload.bodyTags || ""}`
|
|
@@ -8387,6 +8395,41 @@ async function renderPage(opts) {
|
|
|
8387
8395
|
const filePath = resolve(opts.outDir, fileName);
|
|
8388
8396
|
await mkdir(dirname(filePath), { recursive: true });
|
|
8389
8397
|
await writeFile(filePath, html, "utf-8");
|
|
8398
|
+
return { route: opts.route, ...readCanonicalLink(html) };
|
|
8399
|
+
}
|
|
8400
|
+
function readCanonicalLink(html) {
|
|
8401
|
+
let canonical;
|
|
8402
|
+
let baseHref;
|
|
8403
|
+
let inHead = false;
|
|
8404
|
+
let templateDepth = 0;
|
|
8405
|
+
const parser = new Parser({
|
|
8406
|
+
onopentag(tag, attrs) {
|
|
8407
|
+
if (tag === "body") {
|
|
8408
|
+
parser.pause();
|
|
8409
|
+
return;
|
|
8410
|
+
}
|
|
8411
|
+
if (tag === "head")
|
|
8412
|
+
inHead = true;
|
|
8413
|
+
if (!inHead)
|
|
8414
|
+
return;
|
|
8415
|
+
if (tag === "template")
|
|
8416
|
+
templateDepth++;
|
|
8417
|
+
if (templateDepth)
|
|
8418
|
+
return;
|
|
8419
|
+
if (tag === "base")
|
|
8420
|
+
baseHref ??= attrs.href;
|
|
8421
|
+
if (tag === "link" && attrs.rel?.toLowerCase().split(/\s+/).includes("canonical"))
|
|
8422
|
+
canonical ??= attrs.href;
|
|
8423
|
+
},
|
|
8424
|
+
onclosetag(tag) {
|
|
8425
|
+
if (tag === "template" && templateDepth)
|
|
8426
|
+
templateDepth--;
|
|
8427
|
+
if (tag === "head")
|
|
8428
|
+
parser.pause();
|
|
8429
|
+
}
|
|
8430
|
+
});
|
|
8431
|
+
parser.end(html);
|
|
8432
|
+
return { canonical, baseHref };
|
|
8390
8433
|
}
|
|
8391
8434
|
function renderPreloadLinks(modules, manifest) {
|
|
8392
8435
|
if (!modules || modules.size === 0)
|
|
@@ -8439,7 +8482,7 @@ function routeToFileName(route) {
|
|
|
8439
8482
|
return `${route}.html`.slice(1);
|
|
8440
8483
|
}
|
|
8441
8484
|
function trailingSlashAlias(route) {
|
|
8442
|
-
if (!route || route
|
|
8485
|
+
if (!route || route.endsWith("/") || isNotFoundPagePath(route))
|
|
8443
8486
|
return;
|
|
8444
8487
|
const file = routeToFileName(route);
|
|
8445
8488
|
if (!file.endsWith(".html") || file.endsWith("/index.html"))
|
|
@@ -8469,6 +8512,55 @@ async function writeTrailingSlashAliases(outDir, routes) {
|
|
|
8469
8512
|
}));
|
|
8470
8513
|
}
|
|
8471
8514
|
|
|
8515
|
+
async function writeSitemap(outDir, siteUrl, pages) {
|
|
8516
|
+
if (!/^https?:\/\//i.test(siteUrl))
|
|
8517
|
+
return;
|
|
8518
|
+
const base = new URL(siteUrl);
|
|
8519
|
+
base.pathname = `${base.pathname.replace(/\/+$/, "")}/`;
|
|
8520
|
+
base.search = "";
|
|
8521
|
+
base.hash = "";
|
|
8522
|
+
const urls = /* @__PURE__ */ new Set();
|
|
8523
|
+
const routesWithCanonical = /* @__PURE__ */ new Set();
|
|
8524
|
+
const fallbacks = /* @__PURE__ */ new Map();
|
|
8525
|
+
for (const { route, canonical, baseHref } of pages) {
|
|
8526
|
+
const routeUrl = new URL(`.${route}`, base);
|
|
8527
|
+
if (isNotFoundPagePath(routeUrl.pathname))
|
|
8528
|
+
continue;
|
|
8529
|
+
const key = routeUrl.href.replace(/\/$/, "");
|
|
8530
|
+
if (canonical !== void 0) {
|
|
8531
|
+
routesWithCanonical.add(key);
|
|
8532
|
+
const documentBase = baseHref ? URL.parse(baseHref, routeUrl) ?? routeUrl : routeUrl;
|
|
8533
|
+
const url = canonical.trim() ? URL.parse(canonical, documentBase) : null;
|
|
8534
|
+
if (url?.origin === base.origin && url.pathname.startsWith(base.pathname) && !isNotFoundPagePath(url.pathname))
|
|
8535
|
+
urls.add(url.href);
|
|
8536
|
+
} else if (!fallbacks.has(key) || routeUrl.pathname.endsWith("/")) {
|
|
8537
|
+
fallbacks.set(key, routeUrl.href);
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
for (const [key, url] of fallbacks) {
|
|
8541
|
+
if (!routesWithCanonical.has(key))
|
|
8542
|
+
urls.add(url);
|
|
8543
|
+
}
|
|
8544
|
+
const sitemap = [
|
|
8545
|
+
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
8546
|
+
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
|
|
8547
|
+
...[...urls].sort().map((url) => ` <url><loc>${escapeHtml(url)}</loc></url>`),
|
|
8548
|
+
"</urlset>",
|
|
8549
|
+
""
|
|
8550
|
+
].join("\n");
|
|
8551
|
+
await Promise.all([
|
|
8552
|
+
writeFile(join(outDir, "sitemap.xml"), sitemap),
|
|
8553
|
+
writeFile(join(outDir, "robots.txt"), `User-agent: *
|
|
8554
|
+
Allow: /
|
|
8555
|
+
|
|
8556
|
+
Sitemap: ${new URL("sitemap.xml", base).href}
|
|
8557
|
+
`, { flag: "wx" }).catch((error) => {
|
|
8558
|
+
if (error.code !== "EEXIST")
|
|
8559
|
+
throw error;
|
|
8560
|
+
})
|
|
8561
|
+
]);
|
|
8562
|
+
}
|
|
8563
|
+
|
|
8472
8564
|
function tryGC() {
|
|
8473
8565
|
if (typeof globalThis.gc === "function")
|
|
8474
8566
|
globalThis.gc();
|
|
@@ -8504,6 +8596,7 @@ async function ssgBuild(valaxyApp, viteConfig = {}, userSsgOptions = {}) {
|
|
|
8504
8596
|
const outDir = isAbsolute$1(configOutDir) ? configOutDir : resolve(options.userRoot, configOutDir);
|
|
8505
8597
|
const ssgTemp = resolve(outDir, ".vite-ssg-temp");
|
|
8506
8598
|
let routePaths = [];
|
|
8599
|
+
let renderedPages;
|
|
8507
8600
|
const defaultConfig = {
|
|
8508
8601
|
...defaultViteConfig,
|
|
8509
8602
|
plugins: await profileBuildPhase("plugins", () => ViteValaxyPlugins(valaxyApp, {}, viteConfig, 2)),
|
|
@@ -8566,7 +8659,7 @@ async function ssgBuild(valaxyApp, viteConfig = {}, userSsgOptions = {}) {
|
|
|
8566
8659
|
);
|
|
8567
8660
|
const concurrency = userSsgOptions.concurrency ?? 20;
|
|
8568
8661
|
consola.info(`Rendering ${colors.yellow(routePaths.length)} pages (concurrency: ${colors.yellow(concurrency)})...`);
|
|
8569
|
-
await profileBuildPhase("render-pages", () => pMap(
|
|
8662
|
+
renderedPages = await profileBuildPhase("render-pages", () => pMap(
|
|
8570
8663
|
routePaths,
|
|
8571
8664
|
(route) => renderPage({
|
|
8572
8665
|
render,
|
|
@@ -8586,11 +8679,7 @@ async function ssgBuild(valaxyApp, viteConfig = {}, userSsgOptions = {}) {
|
|
|
8586
8679
|
await rm(resolve(outDir, ".vite"), { recursive: true, force: true }).catch(() => {
|
|
8587
8680
|
});
|
|
8588
8681
|
}
|
|
8589
|
-
|
|
8590
|
-
hostname: options.config.siteConfig.url,
|
|
8591
|
-
outDir,
|
|
8592
|
-
exclude: notFoundSitemapPaths(routePaths)
|
|
8593
|
-
});
|
|
8682
|
+
await writeSitemap(outDir, options.config.siteConfig.url, renderedPages);
|
|
8594
8683
|
await writeTrailingSlashAliases(outDir, routePaths);
|
|
8595
8684
|
if (userSsgOptions.onFinished)
|
|
8596
8685
|
await userSsgOptions.onFinished();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "me@yunyoujun.cn",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"@unhead/bundler": "^3.4.1",
|
|
77
77
|
"@unhead/schema-org": "^3.4.1",
|
|
78
78
|
"@unhead/vue": "^3.4.1",
|
|
79
|
-
"@valaxyjs/devtools": "1.3.
|
|
80
|
-
"@valaxyjs/utils": "1.3.
|
|
79
|
+
"@valaxyjs/devtools": "1.3.3",
|
|
80
|
+
"@valaxyjs/utils": "1.3.3",
|
|
81
81
|
"@vitejs/devtools": "0.8.0",
|
|
82
82
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
83
83
|
"@vueuse/core": "^15.0.0",
|
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
"fuse.js": "^7.5.0",
|
|
98
98
|
"hookable": "^6.1.2",
|
|
99
99
|
"html-to-text": "^10.0.1",
|
|
100
|
+
"htmlparser2": "^10.1.0",
|
|
100
101
|
"jiti": "^2.7.0",
|
|
101
102
|
"js-base64": "^3.9.4",
|
|
102
103
|
"js-yaml": "^5.4.2",
|
|
@@ -142,7 +143,6 @@
|
|
|
142
143
|
"vanilla-lazyload": "^19.1.3",
|
|
143
144
|
"vite": "^8.3.6",
|
|
144
145
|
"vite-plugin-vue-devtools": "^8.2.1",
|
|
145
|
-
"vite-ssg-sitemap": "^0.10.0",
|
|
146
146
|
"vitepress-plugin-group-icons": "^1.7.6",
|
|
147
147
|
"vue-i18n": "^11.4.18",
|
|
148
148
|
"yargs": "^18.1.0"
|
package/shared/page-policy.ts
CHANGED
|
@@ -111,13 +111,7 @@ export function omitProductionDraftRoutes<T extends DraftRoute>(routes: T[], inc
|
|
|
111
111
|
})
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
export function
|
|
116
|
-
|
|
117
|
-
for (const route of routes) {
|
|
118
|
-
const path = route.length > 1 && route.endsWith('/') ? route.slice(0, -1) : route
|
|
119
|
-
if (path === '/404' || path.endsWith('/404'))
|
|
120
|
-
paths.add(path)
|
|
121
|
-
}
|
|
122
|
-
return [...paths]
|
|
114
|
+
/** Paths reserved for a site's not-found document. */
|
|
115
|
+
export function isNotFoundPagePath(path: string): boolean {
|
|
116
|
+
return /\/404(?:\.html|\/(?:index\.html)?)?$/.test(path)
|
|
123
117
|
}
|