valaxy 0.26.8 → 0.26.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/dist/node/cli/index.mjs +3 -3
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.mjs +3 -3
- package/dist/shared/{valaxy.DHoKJedg.mjs → valaxy.Cwk84srC.mjs} +117 -85
- package/dist/shared/{valaxy.DJquM_xq.d.mts → valaxy.gqLhCu14.d.mts} +7 -2
- package/dist/types/index.d.mts +2 -2
- package/package.json +9 -8
- package/shared/node/i18n.ts +65 -0
- package/types/config.ts +7 -2
package/dist/node/cli/index.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import 'node:process';
|
|
2
2
|
import 'yargs';
|
|
3
3
|
import 'yargs/helpers';
|
|
4
|
-
export { c as cli, d as registerDevCommand, r as run, a as startValaxyDev } from '../../shared/valaxy.
|
|
4
|
+
export { c as cli, d as registerDevCommand, r as run, a as startValaxyDev } from '../../shared/valaxy.Cwk84srC.mjs';
|
|
5
|
+
import 'node:os';
|
|
5
6
|
import 'node:path';
|
|
6
7
|
import 'consola';
|
|
7
8
|
import 'consola/utils';
|
|
8
9
|
import 'fast-glob';
|
|
9
10
|
import 'fs-extra';
|
|
10
11
|
import 'gray-matter';
|
|
12
|
+
import 'js-yaml';
|
|
11
13
|
import '@antfu/utils';
|
|
12
14
|
import 'debug';
|
|
13
15
|
import 'pathe';
|
|
@@ -20,7 +22,6 @@ import 'ora';
|
|
|
20
22
|
import 'cross-spawn';
|
|
21
23
|
import 'mlly';
|
|
22
24
|
import 'resolve-global';
|
|
23
|
-
import 'js-yaml';
|
|
24
25
|
import 'node:fs/promises';
|
|
25
26
|
import 'dayjs';
|
|
26
27
|
import 'feed';
|
|
@@ -56,7 +57,6 @@ import 'pascalcase';
|
|
|
56
57
|
import 'lru-cache';
|
|
57
58
|
import 'html-to-text';
|
|
58
59
|
import 'unplugin-vue-router/vite';
|
|
59
|
-
import 'node:os';
|
|
60
60
|
import '@clack/prompts';
|
|
61
61
|
import 'node:net';
|
|
62
62
|
import 'node:child_process';
|
package/dist/node/index.d.mts
CHANGED
|
@@ -13,7 +13,7 @@ import { EditableTreeNode } from 'unplugin-vue-router';
|
|
|
13
13
|
import Router from 'unplugin-vue-router/vite';
|
|
14
14
|
import Layouts from 'vite-plugin-vue-layouts';
|
|
15
15
|
import { Options as Options$1 } from 'vitepress-plugin-group-icons';
|
|
16
|
-
import { D as DefaultTheme, R as RuntimeConfig, a as RedirectItem, V as ValaxyConfig, P as PartialDeep, b as ValaxyAddon, S as SiteConfig, U as UserSiteConfig } from '../shared/valaxy.
|
|
16
|
+
import { D as DefaultTheme, R as RuntimeConfig, a as RedirectItem, V as ValaxyConfig, P as PartialDeep, b as ValaxyAddon, S as SiteConfig, U as UserSiteConfig } from '../shared/valaxy.gqLhCu14.mjs';
|
|
17
17
|
import { MarkdownEnv } from 'unplugin-vue-markdown/types';
|
|
18
18
|
import { KatexOptions } from 'katex';
|
|
19
19
|
import MarkdownIt from 'markdown-it';
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, N as createServer, L as createValaxyPlugin, D as customElements, j as defaultSiteConfig, w as defaultValaxyConfig, F as defaultViteConfig, h as defineAddon, y as defineConfig, k as defineSiteConfig, u as defineTheme, f as defineValaxyAddon, x as defineValaxyConfig, t as defineValaxyTheme, O as encryptContent, g as generateClientRedirects, Q as getGitTimestamp, e as getIndexHtml, M as getServerInfoText, R as isExternal, U as isInstalledGlobally, S as isPath, v as loadConfigFromFile, A as mergeValaxyConfig, m as mergeViteConfigs, p as postProcessForSSG, I as processValaxyOptions, d as registerDevCommand, i as resolveAddonsConfig, Y as resolveImportPath, W as resolveImportUrl, J as resolveOptions, n as resolveSiteConfig, l as resolveSiteConfigFromRoot, o as resolveThemeConfigFromRoot, K as resolveThemeValaxyConfig, q as resolveUserThemeConfig, B as resolveValaxyConfig, z as resolveValaxyConfigFromRoot, r as run, s as ssgBuild, a as startValaxyDev, X as toAtFS, T as transformObject, H as version } from '../shared/valaxy.
|
|
1
|
+
export { C as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, N as createServer, L as createValaxyPlugin, D as customElements, j as defaultSiteConfig, w as defaultValaxyConfig, F as defaultViteConfig, h as defineAddon, y as defineConfig, k as defineSiteConfig, u as defineTheme, f as defineValaxyAddon, x as defineValaxyConfig, t as defineValaxyTheme, O as encryptContent, g as generateClientRedirects, Q as getGitTimestamp, e as getIndexHtml, M as getServerInfoText, R as isExternal, U as isInstalledGlobally, S as isPath, v as loadConfigFromFile, A as mergeValaxyConfig, m as mergeViteConfigs, p as postProcessForSSG, I as processValaxyOptions, d as registerDevCommand, i as resolveAddonsConfig, Y as resolveImportPath, W as resolveImportUrl, J as resolveOptions, n as resolveSiteConfig, l as resolveSiteConfigFromRoot, o as resolveThemeConfigFromRoot, K as resolveThemeValaxyConfig, q as resolveUserThemeConfig, B as resolveValaxyConfig, z as resolveValaxyConfigFromRoot, r as run, s as ssgBuild, a as startValaxyDev, X as toAtFS, T as transformObject, H as version } from '../shared/valaxy.Cwk84srC.mjs';
|
|
2
2
|
import 'node:path';
|
|
3
3
|
import 'fs-extra';
|
|
4
4
|
import 'consola/utils';
|
|
@@ -6,9 +6,11 @@ import 'node:process';
|
|
|
6
6
|
import 'define-config-ts';
|
|
7
7
|
import 'yargs';
|
|
8
8
|
import 'yargs/helpers';
|
|
9
|
+
import 'node:os';
|
|
9
10
|
import 'consola';
|
|
10
11
|
import 'fast-glob';
|
|
11
12
|
import 'gray-matter';
|
|
13
|
+
import 'js-yaml';
|
|
12
14
|
import '@antfu/utils';
|
|
13
15
|
import 'debug';
|
|
14
16
|
import 'pathe';
|
|
@@ -20,7 +22,6 @@ import 'ora';
|
|
|
20
22
|
import 'cross-spawn';
|
|
21
23
|
import 'mlly';
|
|
22
24
|
import 'resolve-global';
|
|
23
|
-
import 'js-yaml';
|
|
24
25
|
import 'node:fs/promises';
|
|
25
26
|
import 'dayjs';
|
|
26
27
|
import 'feed';
|
|
@@ -56,7 +57,6 @@ import 'pascalcase';
|
|
|
56
57
|
import 'lru-cache';
|
|
57
58
|
import 'html-to-text';
|
|
58
59
|
import 'unplugin-vue-router/vite';
|
|
59
|
-
import 'node:os';
|
|
60
60
|
import '@clack/prompts';
|
|
61
61
|
import 'node:net';
|
|
62
62
|
import 'node:child_process';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
+
import os from 'node:os';
|
|
4
5
|
import path$1, { join, dirname, resolve } from 'node:path';
|
|
5
6
|
import { consola } from 'consola';
|
|
6
7
|
import { colors } from 'consola/utils';
|
|
7
8
|
import fg from 'fast-glob';
|
|
8
9
|
import fs from 'fs-extra';
|
|
9
10
|
import matter from 'gray-matter';
|
|
11
|
+
import yaml, { CORE_SCHEMA } from 'js-yaml';
|
|
10
12
|
import { ensurePrefix, slash, uniq, objectEntries, isObject, isFunction, ensureSuffix } from '@antfu/utils';
|
|
11
13
|
import _debug from 'debug';
|
|
12
14
|
import path, { resolve as resolve$1, join as join$1, relative } from 'pathe';
|
|
@@ -19,7 +21,6 @@ import ora from 'ora';
|
|
|
19
21
|
import { spawn } from 'cross-spawn';
|
|
20
22
|
import { resolvePath } from 'mlly';
|
|
21
23
|
import { resolveGlobal } from 'resolve-global';
|
|
22
|
-
import yaml, { CORE_SCHEMA } from 'js-yaml';
|
|
23
24
|
import { readFile } from 'node:fs/promises';
|
|
24
25
|
import dayjs from 'dayjs';
|
|
25
26
|
import { Feed } from 'feed';
|
|
@@ -55,7 +56,6 @@ import pascalCase from 'pascalcase';
|
|
|
55
56
|
import { LRUCache } from 'lru-cache';
|
|
56
57
|
import { convert } from 'html-to-text';
|
|
57
58
|
import VueRouter from 'unplugin-vue-router/vite';
|
|
58
|
-
import os from 'node:os';
|
|
59
59
|
import { intro, confirm, select, outro } from '@clack/prompts';
|
|
60
60
|
import net from 'node:net';
|
|
61
61
|
import { exec } from 'node:child_process';
|
|
@@ -162,6 +162,7 @@ function getGitTimestamp(file, type = "updated") {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
const EXTERNAL_URL_RE = /^(?:[a-z]+:|\/\/)/i;
|
|
165
|
+
const LOCALE_PREFIX = "$locale:";
|
|
165
166
|
|
|
166
167
|
function tObject(data, lang) {
|
|
167
168
|
if (data && typeof data === "object") {
|
|
@@ -436,6 +437,51 @@ async function getAlias(options) {
|
|
|
436
437
|
return alias;
|
|
437
438
|
}
|
|
438
439
|
|
|
440
|
+
const LOCAL_SEARCH_INDEX_ID = "@localSearchIndex";
|
|
441
|
+
const LOCAL_SEARCH_INDEX_REQUEST_PATH = `/${LOCAL_SEARCH_INDEX_ID}`;
|
|
442
|
+
async function localSearchPlugin(options) {
|
|
443
|
+
const siteConfig = options.config.siteConfig;
|
|
444
|
+
if (siteConfig.search?.provider !== "local") {
|
|
445
|
+
return {
|
|
446
|
+
name: "valaxy:local-search",
|
|
447
|
+
resolveId(id) {
|
|
448
|
+
if (id.startsWith(LOCAL_SEARCH_INDEX_ID)) {
|
|
449
|
+
return LOCAL_SEARCH_INDEX_REQUEST_PATH;
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
load(id) {
|
|
453
|
+
if (id.startsWith(LOCAL_SEARCH_INDEX_REQUEST_PATH)) {
|
|
454
|
+
return `export default '{}'`;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
return {
|
|
460
|
+
name: "valaxy:local-search",
|
|
461
|
+
config: () => {
|
|
462
|
+
return {
|
|
463
|
+
optimizeDeps: {
|
|
464
|
+
include: [
|
|
465
|
+
"valaxy > @vueuse/integrations/useFocusTrap",
|
|
466
|
+
"valaxy > mark.js/src/vanilla.js",
|
|
467
|
+
"valaxy > minisearch"
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
// async configureServer(_server) {
|
|
471
|
+
// server = _server
|
|
472
|
+
// await scanForBuild()
|
|
473
|
+
// onIndexUpdated()
|
|
474
|
+
// },
|
|
475
|
+
// resolveId(id) {
|
|
476
|
+
// if (id.startsWith(LOCAL_SEARCH_INDEX_ID)) {
|
|
477
|
+
// return `/${id}`
|
|
478
|
+
// }
|
|
479
|
+
// },
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
439
485
|
const logger = consola.create({});
|
|
440
486
|
const valaxyPrefix = colors.magenta("[valaxy]");
|
|
441
487
|
const vLogger = {
|
|
@@ -1466,21 +1512,6 @@ function snippetPlugin(md, srcDir) {
|
|
|
1466
1512
|
md.block.ruler.before("fence", "snippet", parser);
|
|
1467
1513
|
}
|
|
1468
1514
|
|
|
1469
|
-
const globalTitleCollector = /* @__PURE__ */ new Set();
|
|
1470
|
-
function getGlobalTitleCollector() {
|
|
1471
|
-
return globalTitleCollector;
|
|
1472
|
-
}
|
|
1473
|
-
function titleCollectorPlugin(md) {
|
|
1474
|
-
const fence = md.renderer.rules.fence;
|
|
1475
|
-
md.renderer.rules.fence = (...args) => {
|
|
1476
|
-
const [tokens, idx] = args;
|
|
1477
|
-
const token = tokens[idx];
|
|
1478
|
-
const title = extractTitle(token.info);
|
|
1479
|
-
globalTitleCollector.add(title);
|
|
1480
|
-
return fence(...args);
|
|
1481
|
-
};
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
1515
|
const defaultCodeTheme = { light: "github-light", dark: "github-dark" };
|
|
1485
1516
|
async function setupMarkdownPlugins(md, options, base = "/") {
|
|
1486
1517
|
const mdOptions = options?.config.markdown || {};
|
|
@@ -1488,7 +1519,7 @@ async function setupMarkdownPlugins(md, options, base = "/") {
|
|
|
1488
1519
|
const siteConfig = options?.config.siteConfig || {};
|
|
1489
1520
|
if (mdOptions.preConfig)
|
|
1490
1521
|
mdOptions.preConfig(md);
|
|
1491
|
-
md.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(
|
|
1522
|
+
md.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
|
|
1492
1523
|
languages: siteConfig.languages,
|
|
1493
1524
|
...mdOptions?.container,
|
|
1494
1525
|
blocks: {
|
|
@@ -1568,7 +1599,7 @@ async function setupMarkdownPlugins(md, options, base = "/") {
|
|
|
1568
1599
|
return md;
|
|
1569
1600
|
}
|
|
1570
1601
|
|
|
1571
|
-
const version = "0.26.
|
|
1602
|
+
const version = "0.26.10";
|
|
1572
1603
|
|
|
1573
1604
|
const GLOBAL_STATE = {
|
|
1574
1605
|
valaxyApp: void 0,
|
|
@@ -2009,7 +2040,7 @@ const defaultSiteConfig = {
|
|
|
2009
2040
|
},
|
|
2010
2041
|
search: {
|
|
2011
2042
|
enable: false,
|
|
2012
|
-
|
|
2043
|
+
provider: "fuse"
|
|
2013
2044
|
},
|
|
2014
2045
|
fuse: {
|
|
2015
2046
|
dataPath: "valaxy-fuse-list.json",
|
|
@@ -3486,7 +3517,9 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
|
|
|
3486
3517
|
fullInstall: true,
|
|
3487
3518
|
include: roots.map((root) => `${root}/locales/**`)
|
|
3488
3519
|
}),
|
|
3489
|
-
createFixPlugins()
|
|
3520
|
+
createFixPlugins(),
|
|
3521
|
+
// localSearch
|
|
3522
|
+
await localSearchPlugin(options)
|
|
3490
3523
|
];
|
|
3491
3524
|
if (valaxyConfig.visualizer) {
|
|
3492
3525
|
try {
|
|
@@ -3513,65 +3546,18 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
|
|
|
3513
3546
|
typedoc: "vscode-icons:file-type-typedoc",
|
|
3514
3547
|
eslint: "vscode-icons:file-type-eslint"
|
|
3515
3548
|
};
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
customIcon: {
|
|
3521
|
-
...builtinCustomIcon,
|
|
3522
|
-
...valaxyConfig.groupIcons?.customIcon
|
|
3523
|
-
},
|
|
3524
|
-
defaultLabels: [
|
|
3525
|
-
...valaxyConfig.groupIcons?.defaultLabels || [],
|
|
3526
|
-
...Object.keys(builtinCustomIcon),
|
|
3527
|
-
...Object.keys(valaxyConfig.groupIcons?.customIcon || {}),
|
|
3528
|
-
...Array.from(codeBlockTitles)
|
|
3529
|
-
]
|
|
3530
|
-
});
|
|
3531
|
-
if (originalPlugin && typeof originalPlugin === "object" && "load" in originalPlugin) {
|
|
3532
|
-
return originalPlugin.load(id);
|
|
3533
|
-
}
|
|
3534
|
-
return "";
|
|
3535
|
-
};
|
|
3536
|
-
const dynamicGroupIconPlugin = {
|
|
3537
|
-
name: "post-process-add-group-icons",
|
|
3538
|
-
enforce: "post",
|
|
3539
|
-
configureServer(server) {
|
|
3540
|
-
const markdownGlobs = roots.map((root) => `${root}/**/*.md`);
|
|
3541
|
-
server.watcher.add(markdownGlobs);
|
|
3542
|
-
server.watcher.on("change", (file) => {
|
|
3543
|
-
if (file.endsWith(".md")) {
|
|
3544
|
-
cachedGroupIconsCSS = null;
|
|
3545
|
-
const module = server.moduleGraph.getModuleById("\0virtual:group-icons.css");
|
|
3546
|
-
if (module) {
|
|
3547
|
-
server.reloadModule(module);
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
});
|
|
3551
|
-
},
|
|
3552
|
-
resolveId(id) {
|
|
3553
|
-
if (id === "virtual:group-icons.css") {
|
|
3554
|
-
return "\0virtual:group-icons.css";
|
|
3555
|
-
}
|
|
3556
|
-
return void 0;
|
|
3549
|
+
const groupIconPlugin = groupIconVitePlugin({
|
|
3550
|
+
customIcon: {
|
|
3551
|
+
...builtinCustomIcon,
|
|
3552
|
+
...valaxyConfig.groupIcons?.customIcon
|
|
3557
3553
|
},
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
return void 0;
|
|
3566
|
-
},
|
|
3567
|
-
// In build mode, regenerate the CSS after all markdown files have been processed
|
|
3568
|
-
generateBundle() {
|
|
3569
|
-
if (this.meta.rollupVersion) {
|
|
3570
|
-
cachedGroupIconsCSS = generateGroupIconsCSS("\0virtual:group-icons.css");
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
|
-
};
|
|
3574
|
-
plugins.push(dynamicGroupIconPlugin);
|
|
3554
|
+
defaultLabels: [
|
|
3555
|
+
...valaxyConfig.groupIcons?.defaultLabels || [],
|
|
3556
|
+
...Object.keys(builtinCustomIcon),
|
|
3557
|
+
...Object.keys(valaxyConfig.groupIcons?.customIcon || {})
|
|
3558
|
+
]
|
|
3559
|
+
});
|
|
3560
|
+
plugins.push(groupIconPlugin);
|
|
3575
3561
|
return plugins;
|
|
3576
3562
|
}
|
|
3577
3563
|
|
|
@@ -3667,6 +3653,48 @@ function setupModules(node, modules) {
|
|
|
3667
3653
|
});
|
|
3668
3654
|
}
|
|
3669
3655
|
|
|
3656
|
+
const NODE_I18N = {
|
|
3657
|
+
/**
|
|
3658
|
+
* node 读取的 locales 数据
|
|
3659
|
+
*/
|
|
3660
|
+
locales: {}
|
|
3661
|
+
};
|
|
3662
|
+
function loadLocalesYml(localesPath) {
|
|
3663
|
+
const locales = {};
|
|
3664
|
+
if (fs.existsSync(localesPath)) {
|
|
3665
|
+
const files = fs.readdirSync(localesPath);
|
|
3666
|
+
files.forEach((file) => {
|
|
3667
|
+
if (file.endsWith(".yml") || file.endsWith(".yaml")) {
|
|
3668
|
+
const lang = file.replace(/\.ya?ml$/, "");
|
|
3669
|
+
const filePath = `${localesPath}/${file}`;
|
|
3670
|
+
try {
|
|
3671
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
3672
|
+
const data = yaml.load(content);
|
|
3673
|
+
locales[lang] = data || {};
|
|
3674
|
+
} catch (e) {
|
|
3675
|
+
console.error(`Error loading locale file: ${filePath}`, e);
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
NODE_I18N.locales = locales;
|
|
3681
|
+
return locales;
|
|
3682
|
+
}
|
|
3683
|
+
function nodeT(key, lang) {
|
|
3684
|
+
if (key.startsWith(LOCALE_PREFIX)) {
|
|
3685
|
+
key = key.slice(LOCALE_PREFIX.length);
|
|
3686
|
+
}
|
|
3687
|
+
const data = NODE_I18N.locales[lang] || {};
|
|
3688
|
+
const keys = key.split(".");
|
|
3689
|
+
let result = data;
|
|
3690
|
+
for (const k of keys) {
|
|
3691
|
+
result = result?.[k];
|
|
3692
|
+
if (result === void 0)
|
|
3693
|
+
return "";
|
|
3694
|
+
}
|
|
3695
|
+
return result || "";
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3670
3698
|
function commonOptions(args) {
|
|
3671
3699
|
return args.positional("root", {
|
|
3672
3700
|
default: ".",
|
|
@@ -3675,15 +3703,19 @@ function commonOptions(args) {
|
|
|
3675
3703
|
});
|
|
3676
3704
|
}
|
|
3677
3705
|
|
|
3706
|
+
const isWindows = os.platform() === "win32";
|
|
3678
3707
|
async function generateFuseList(options) {
|
|
3679
3708
|
consola.start(`Generate List for Fuse Search by (${colors.cyan("fuse.js")}) ...`);
|
|
3680
3709
|
const pattern = path$1.resolve(options.userRoot, options.config.siteConfig.fuse.pattern || "pages/**/*.md");
|
|
3681
|
-
const
|
|
3710
|
+
const finalPattern = isWindows ? fg.convertPathToPattern(pattern) : pattern;
|
|
3711
|
+
const files = await fg(finalPattern);
|
|
3682
3712
|
if (files.length > 0) {
|
|
3683
3713
|
consola.success(`Found ${colors.dim(files.length.toString())} markdown files for fuse search.`);
|
|
3684
3714
|
} else {
|
|
3685
|
-
consola.warn(`No markdown files found for fuse search. Please check your fuse pattern: ${colors.dim(
|
|
3715
|
+
consola.warn(`No markdown files found for fuse search. Please check your fuse pattern: ${colors.dim(finalPattern)}`);
|
|
3686
3716
|
}
|
|
3717
|
+
loadLocalesYml(path$1.resolve(options.userRoot, "locales"));
|
|
3718
|
+
const globalAuthor = nodeT(options.config.siteConfig.author.name, options.config.siteConfig.lang || "en");
|
|
3687
3719
|
const posts = [];
|
|
3688
3720
|
for await (const i of files) {
|
|
3689
3721
|
const raw = fs.readFileSync(i, "utf-8");
|
|
@@ -3698,15 +3730,15 @@ async function generateFuseList(options) {
|
|
|
3698
3730
|
if (fmData.password)
|
|
3699
3731
|
continue;
|
|
3700
3732
|
const extendKeys = options.config.fuse?.extendKeys || [];
|
|
3701
|
-
const relativeLink = path$1.
|
|
3733
|
+
const relativeLink = path$1.join(options.config.vite?.base || "/", path$1.relative(path$1.resolve(options.userRoot, "pages"), i)).replace(/\\/g, "/");
|
|
3702
3734
|
const link = i.endsWith("index.md") ? relativeLink.replace(/\/index\.md$/, "") : relativeLink.replace(/\.md$/, "");
|
|
3703
3735
|
const fuseListItem = {
|
|
3704
3736
|
title: fmData.title || "",
|
|
3705
3737
|
tags: (typeof fmData.tags === "string" ? [fmData.tags] : fmData.tags) || [],
|
|
3706
3738
|
categories: (typeof fmData.categories === "string" ? [fmData.categories] : fmData.categories) || [],
|
|
3707
|
-
author:
|
|
3739
|
+
author: fmData.author || globalAuthor,
|
|
3708
3740
|
excerpt: excerpt || content.slice(0, 100),
|
|
3709
|
-
// encode for chinese url
|
|
3741
|
+
// encode for chinese url, replace for windows path
|
|
3710
3742
|
link: encodeURI(link)
|
|
3711
3743
|
};
|
|
3712
3744
|
if (options.config.siteConfig.fuse.options.keys?.includes("content")) {
|
|
@@ -4092,7 +4124,7 @@ async function execBuild({ ssg, root, output, log }) {
|
|
|
4092
4124
|
const valaxyApp = createValaxyNode(options);
|
|
4093
4125
|
await callHookWithLog("options:resolved", valaxyApp);
|
|
4094
4126
|
const modules = [];
|
|
4095
|
-
if (options.config.siteConfig.search.
|
|
4127
|
+
if (options.config.siteConfig.search.provider === "fuse")
|
|
4096
4128
|
modules.push(fuseModule);
|
|
4097
4129
|
if (options.config.modules.rss.enable)
|
|
4098
4130
|
modules.push(rssModule);
|
|
@@ -569,20 +569,25 @@ interface SiteConfig {
|
|
|
569
569
|
* @zh 是否启用
|
|
570
570
|
*/
|
|
571
571
|
enable: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* @deprecated will be deprecated, use search.provider instead
|
|
574
|
+
*/
|
|
575
|
+
type?: SiteConfig['search']['provider'];
|
|
572
576
|
/**
|
|
573
577
|
* Search Type
|
|
574
578
|
* - algolia: Algolia Search
|
|
575
579
|
* - engine: Engine Search, like Google/Baidu
|
|
576
580
|
* - fuse: Local Search by fuse.js
|
|
581
|
+
* - local(todo): Local Search by MiniSearch
|
|
577
582
|
*/
|
|
578
|
-
|
|
583
|
+
provider: 'algolia' | 'engine' | 'fuse' | 'local';
|
|
579
584
|
};
|
|
580
585
|
/**
|
|
581
586
|
*
|
|
582
587
|
* fuse search
|
|
583
588
|
* @see https://fusejs.io/
|
|
584
589
|
* @description 本地搜索
|
|
585
|
-
* Please set search.
|
|
590
|
+
* Please set search.provider to 'fuse'
|
|
586
591
|
*/
|
|
587
592
|
fuse: {
|
|
588
593
|
/**
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as PostFrontMatter, d as PageFrontMatter } from '../shared/valaxy.
|
|
2
|
-
export { A as Album, B as BaseFrontMatter, D as DefaultTheme, E as ExcerptType, F as FuseListItem, P as PartialDeep, i as Photo, g as Pkg, a as RedirectItem, f as RedirectRule, R as RuntimeConfig, S as SiteConfig, e as SocialLink, U as UserSiteConfig, h as UserValaxyConfig, b as ValaxyAddon, V as ValaxyConfig } from '../shared/valaxy.
|
|
1
|
+
import { c as PostFrontMatter, d as PageFrontMatter } from '../shared/valaxy.gqLhCu14.mjs';
|
|
2
|
+
export { A as Album, B as BaseFrontMatter, D as DefaultTheme, E as ExcerptType, F as FuseListItem, P as PartialDeep, i as Photo, g as Pkg, a as RedirectItem, f as RedirectRule, R as RuntimeConfig, S as SiteConfig, e as SocialLink, U as UserSiteConfig, h as UserValaxyConfig, b as ValaxyAddon, V as ValaxyConfig } from '../shared/valaxy.gqLhCu14.mjs';
|
|
3
3
|
import { Header } from '@valaxyjs/utils';
|
|
4
4
|
import '@vueuse/integrations/useFuse';
|
|
5
5
|
import 'medium-zoom';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.26.
|
|
4
|
+
"version": "0.26.10",
|
|
5
5
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "me@yunyoujun.cn",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@clack/prompts": "^0.11.0",
|
|
66
66
|
"@iconify-json/ri": "^1.2.6",
|
|
67
67
|
"@intlify/unplugin-vue-i18n": "^11.0.1",
|
|
68
|
-
"@shikijs/transformers": "^3.
|
|
68
|
+
"@shikijs/transformers": "^3.15.0",
|
|
69
69
|
"@types/katex": "^0.16.7",
|
|
70
70
|
"@unhead/addons": "^2.0.19",
|
|
71
71
|
"@unhead/schema-org": "^2.0.19",
|
|
@@ -115,11 +115,11 @@
|
|
|
115
115
|
"ora": "^9.0.0",
|
|
116
116
|
"pascalcase": "^2.0.0",
|
|
117
117
|
"pathe": "^2.0.3",
|
|
118
|
-
"pinia": "^3.0.
|
|
118
|
+
"pinia": "^3.0.4",
|
|
119
119
|
"qrcode": "^1.5.4",
|
|
120
120
|
"resolve-global": "^2.0.0",
|
|
121
121
|
"sass": "^1.93.3",
|
|
122
|
-
"shiki": "^3.
|
|
122
|
+
"shiki": "^3.15.0",
|
|
123
123
|
"star-markdown-css": "^0.5.3",
|
|
124
124
|
"table": "^6.9.0",
|
|
125
125
|
"unhead": "^2.0.19",
|
|
@@ -128,19 +128,19 @@
|
|
|
128
128
|
"unplugin-vue-markdown": "^29.2.0",
|
|
129
129
|
"unplugin-vue-router": "^0.16.1",
|
|
130
130
|
"vanilla-lazyload": "^19.1.3",
|
|
131
|
-
"vite": "^7.1
|
|
131
|
+
"vite": "^7.2.1",
|
|
132
132
|
"vite-dev-rpc": "^1.1.0",
|
|
133
133
|
"vite-plugin-vue-devtools": "^8.0.3",
|
|
134
134
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
135
135
|
"vite-ssg": "^28.2.2",
|
|
136
136
|
"vite-ssg-sitemap": "^0.10.0",
|
|
137
137
|
"vitepress-plugin-group-icons": "^1.6.5",
|
|
138
|
-
"vue": "
|
|
138
|
+
"vue": "3.5.22",
|
|
139
139
|
"vue-i18n": "^11.1.12",
|
|
140
140
|
"vue-router": "^4.6.3",
|
|
141
141
|
"yargs": "^18.0.0",
|
|
142
|
-
"@valaxyjs/
|
|
143
|
-
"@valaxyjs/
|
|
142
|
+
"@valaxyjs/devtools": "0.26.10",
|
|
143
|
+
"@valaxyjs/utils": "0.26.10"
|
|
144
144
|
},
|
|
145
145
|
"devDependencies": {
|
|
146
146
|
"@mdit-vue/plugin-component": "^3.0.2",
|
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
"diacritics": "^1.3.0",
|
|
166
166
|
"gh-pages": "^6.3.0",
|
|
167
167
|
"https-localhost": "^4.7.1",
|
|
168
|
+
"p-map": "^7.0.3",
|
|
168
169
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
169
170
|
"unbuild": "^3.6.1"
|
|
170
171
|
},
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import fs from 'fs-extra'
|
|
2
|
+
import yaml from 'js-yaml'
|
|
3
|
+
import { LOCALE_PREFIX } from '../constants'
|
|
4
|
+
|
|
5
|
+
export const NODE_I18N: {
|
|
6
|
+
locales: Record<string, any>
|
|
7
|
+
} = {
|
|
8
|
+
/**
|
|
9
|
+
* node 读取的 locales 数据
|
|
10
|
+
*/
|
|
11
|
+
locales: {},
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 读取翻译 yml 文件
|
|
16
|
+
*/
|
|
17
|
+
export function loadLocalesYml(localesPath: string): Record<string, any> {
|
|
18
|
+
/**
|
|
19
|
+
* read locales dir *.yml
|
|
20
|
+
*/
|
|
21
|
+
const locales: Record<string, any> = {}
|
|
22
|
+
if (fs.existsSync(localesPath)) {
|
|
23
|
+
const files = fs.readdirSync(localesPath)
|
|
24
|
+
files.forEach((file) => {
|
|
25
|
+
if (file.endsWith('.yml') || file.endsWith('.yaml')) {
|
|
26
|
+
const lang = file.replace(/\.ya?ml$/, '')
|
|
27
|
+
const filePath = `${localesPath}/${file}`
|
|
28
|
+
try {
|
|
29
|
+
const content = fs.readFileSync(filePath, 'utf-8')
|
|
30
|
+
const data = yaml.load(content)
|
|
31
|
+
locales[lang] = data || {}
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
console.error(`Error loading locale file: ${filePath}`, e)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// cache
|
|
41
|
+
NODE_I18N.locales = locales
|
|
42
|
+
return locales
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* node translate function
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* nodeT('greeting.hello', 'en') // 'Hello'
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function nodeT(key: string, lang: string): string {
|
|
53
|
+
if (key.startsWith(LOCALE_PREFIX)) {
|
|
54
|
+
key = key.slice(LOCALE_PREFIX.length)
|
|
55
|
+
}
|
|
56
|
+
const data = NODE_I18N.locales[lang] || {}
|
|
57
|
+
const keys = key.split('.')
|
|
58
|
+
let result: any = data
|
|
59
|
+
for (const k of keys) {
|
|
60
|
+
result = result?.[k]
|
|
61
|
+
if (result === undefined)
|
|
62
|
+
return ''
|
|
63
|
+
}
|
|
64
|
+
return result || ''
|
|
65
|
+
}
|
package/types/config.ts
CHANGED
|
@@ -171,13 +171,18 @@ export interface SiteConfig {
|
|
|
171
171
|
* @zh 是否启用
|
|
172
172
|
*/
|
|
173
173
|
enable: boolean
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated will be deprecated, use search.provider instead
|
|
176
|
+
*/
|
|
177
|
+
type?: SiteConfig['search']['provider']
|
|
174
178
|
/**
|
|
175
179
|
* Search Type
|
|
176
180
|
* - algolia: Algolia Search
|
|
177
181
|
* - engine: Engine Search, like Google/Baidu
|
|
178
182
|
* - fuse: Local Search by fuse.js
|
|
183
|
+
* - local(todo): Local Search by MiniSearch
|
|
179
184
|
*/
|
|
180
|
-
|
|
185
|
+
provider: 'algolia' | 'engine' | 'fuse' | 'local'
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
/**
|
|
@@ -185,7 +190,7 @@ export interface SiteConfig {
|
|
|
185
190
|
* fuse search
|
|
186
191
|
* @see https://fusejs.io/
|
|
187
192
|
* @description 本地搜索
|
|
188
|
-
* Please set search.
|
|
193
|
+
* Please set search.provider to 'fuse'
|
|
189
194
|
*/
|
|
190
195
|
fuse: {
|
|
191
196
|
/**
|