valaxy 0.24.4 → 0.25.0
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/components/ValaxyCopyright.vue +3 -1
- package/client/composables/app/useValaxyApp.ts +3 -2
- package/client/composables/app/useValaxyHead.ts +4 -3
- package/client/composables/locale.ts +21 -0
- package/dist/{chunk-PX37TXCH.js → chunk-VNLGPNVS.js} +23 -9
- package/dist/node/cli/index.js +1 -1
- package/dist/node/index.d.ts +11 -1
- package/dist/node/index.js +3 -1
- package/package.json +3 -3
- package/shared/constants.ts +7 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import { useI18n } from 'vue-i18n'
|
|
4
|
+
import { useValaxyI18n } from '../composables'
|
|
4
5
|
import { useSiteConfig } from '../config'
|
|
5
6
|
|
|
6
7
|
withDefaults(defineProps<{
|
|
@@ -10,6 +11,7 @@ withDefaults(defineProps<{
|
|
|
10
11
|
})
|
|
11
12
|
|
|
12
13
|
const { t, locale } = useI18n()
|
|
14
|
+
const { $t } = useValaxyI18n()
|
|
13
15
|
|
|
14
16
|
const siteConfig = useSiteConfig()
|
|
15
17
|
|
|
@@ -31,7 +33,7 @@ const licenseHtml = computed(() => {
|
|
|
31
33
|
<strong>
|
|
32
34
|
{{ t('post.copyright.author') + t('symbol.colon') }}
|
|
33
35
|
</strong>
|
|
34
|
-
<span>{{ t(siteConfig.author.name) }}</span>
|
|
36
|
+
<span>{{ $t(siteConfig.author.name) }}</span>
|
|
35
37
|
</li>
|
|
36
38
|
<li v-if="url" class="post-copyright-link">
|
|
37
39
|
<strong>
|
|
@@ -6,7 +6,7 @@ import { computed } from 'vue'
|
|
|
6
6
|
import { useI18n } from 'vue-i18n'
|
|
7
7
|
|
|
8
8
|
import { tObject } from '../../../shared/utils/i18n'
|
|
9
|
-
import { useFrontmatter, useValaxyHead } from '../../composables'
|
|
9
|
+
import { useFrontmatter, useValaxyHead, useValaxyI18n } from '../../composables'
|
|
10
10
|
|
|
11
11
|
import { useTimezone } from '../../composables/global'
|
|
12
12
|
// https://github.com/vueuse/head
|
|
@@ -20,6 +20,7 @@ export function useValaxyApp() {
|
|
|
20
20
|
const fm = useFrontmatter()
|
|
21
21
|
|
|
22
22
|
const { locale } = useI18n()
|
|
23
|
+
const { $t } = useValaxyI18n()
|
|
23
24
|
|
|
24
25
|
const title = computed(() => tObject(fm.value.title || '', locale.value))
|
|
25
26
|
|
|
@@ -45,7 +46,7 @@ export function useValaxyApp() {
|
|
|
45
46
|
// https://unhead.unjs.io/docs/schema-org/guides/recipes/identity
|
|
46
47
|
// Personal Website or Blog
|
|
47
48
|
definePerson({
|
|
48
|
-
name: siteConfig.value.author.name,
|
|
49
|
+
name: $t(siteConfig.value.author.name),
|
|
49
50
|
url: siteUrl.value,
|
|
50
51
|
image: siteConfig.value.author.avatar,
|
|
51
52
|
sameAs: siteConfig.value.social.map(s => s.link),
|
|
@@ -3,12 +3,13 @@ import pkg from 'valaxy/package.json'
|
|
|
3
3
|
import { computed } from 'vue'
|
|
4
4
|
import { useI18n } from 'vue-i18n'
|
|
5
5
|
|
|
6
|
-
import { useFrontmatter } from '../../composables'
|
|
6
|
+
import { useFrontmatter, useValaxyI18n } from '../../composables'
|
|
7
7
|
import { useSiteConfig } from '../../config'
|
|
8
8
|
import { tObject } from '../../utils'
|
|
9
9
|
|
|
10
10
|
export function useValaxyHead() {
|
|
11
|
-
const { locale
|
|
11
|
+
const { locale } = useI18n()
|
|
12
|
+
const { $t } = useValaxyI18n()
|
|
12
13
|
|
|
13
14
|
const fm = useFrontmatter()
|
|
14
15
|
const siteConfig = useSiteConfig()
|
|
@@ -17,7 +18,7 @@ export function useValaxyHead() {
|
|
|
17
18
|
useHead({
|
|
18
19
|
title: $title,
|
|
19
20
|
titleTemplate: (title) => {
|
|
20
|
-
const siteTitle = t(siteConfig.value.title)
|
|
21
|
+
const siteTitle = $t(siteConfig.value.title)
|
|
21
22
|
return fm.value.titleTemplate || (title ? `${title} - ${siteTitle}` : siteTitle)
|
|
22
23
|
},
|
|
23
24
|
link: [
|
|
@@ -6,6 +6,7 @@ import { computed } from 'vue'
|
|
|
6
6
|
// not optimize deps all locales
|
|
7
7
|
import { useI18n } from 'vue-i18n'
|
|
8
8
|
import { tObject } from '../../shared/utils/i18n'
|
|
9
|
+
import { LOCALE_PREFIX } from '../utils'
|
|
9
10
|
import 'dayjs/locale/en'
|
|
10
11
|
import 'dayjs/locale/zh-cn'
|
|
11
12
|
|
|
@@ -63,3 +64,23 @@ export function useLocaleTitle(fm: Ref<{
|
|
|
63
64
|
return tObject(fm.value.title || '', lang) || ''
|
|
64
65
|
})
|
|
65
66
|
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @experimental
|
|
70
|
+
* 以 `$locale:` 开头的 key 会被认为是国际化的 key
|
|
71
|
+
* 会从 locales/ 目录中获取对应的翻译
|
|
72
|
+
*/
|
|
73
|
+
export function useValaxyI18n() {
|
|
74
|
+
const { t, locale } = useI18n()
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
locale,
|
|
78
|
+
|
|
79
|
+
$t: (key: string) => {
|
|
80
|
+
if (key.startsWith(LOCALE_PREFIX)) {
|
|
81
|
+
return t(key.slice(LOCALE_PREFIX.length))
|
|
82
|
+
}
|
|
83
|
+
return key
|
|
84
|
+
},
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -4,7 +4,7 @@ import yargs from "yargs";
|
|
|
4
4
|
import { hideBin } from "yargs/helpers";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.
|
|
7
|
+
var version = "0.25.0";
|
|
8
8
|
|
|
9
9
|
// node/modules/fuse.ts
|
|
10
10
|
import path4 from "path";
|
|
@@ -537,6 +537,11 @@ function transformObject(obj) {
|
|
|
537
537
|
return `JSON.parse(${JSON.stringify(JSON.stringify(obj))})`;
|
|
538
538
|
}
|
|
539
539
|
|
|
540
|
+
// node/utils/i18n.ts
|
|
541
|
+
function $t(key) {
|
|
542
|
+
return `$locale:${key}`;
|
|
543
|
+
}
|
|
544
|
+
|
|
540
545
|
// node/utils/resolve.ts
|
|
541
546
|
import { ensurePrefix, slash } from "@antfu/utils";
|
|
542
547
|
import { consola as consola6 } from "consola";
|
|
@@ -1326,7 +1331,6 @@ var clientDeps = [
|
|
|
1326
1331
|
// vue
|
|
1327
1332
|
"vue",
|
|
1328
1333
|
"vue-router",
|
|
1329
|
-
"unplugin-vue-router/data-loaders/basic",
|
|
1330
1334
|
"vue-i18n",
|
|
1331
1335
|
// dev
|
|
1332
1336
|
"@vue/devtools-api",
|
|
@@ -1355,7 +1359,12 @@ var EXCLUDE = [
|
|
|
1355
1359
|
"/@valaxyjs/context",
|
|
1356
1360
|
"/@valaxyjs/addons",
|
|
1357
1361
|
"/@valaxyjs/locales",
|
|
1358
|
-
"/@valaxyjs/styles"
|
|
1362
|
+
"/@valaxyjs/styles",
|
|
1363
|
+
/**
|
|
1364
|
+
* unplugin-vue-router
|
|
1365
|
+
* exclude to avoid vite optimize, will make Symbol('loaderEntries') valid
|
|
1366
|
+
*/
|
|
1367
|
+
"unplugin-vue-router/data-loaders/basic"
|
|
1359
1368
|
];
|
|
1360
1369
|
function createConfigPlugin(options) {
|
|
1361
1370
|
const addonDeps = options.addons.map((i) => Object.keys(i.pkg.dependencies || {})).flat();
|
|
@@ -2136,7 +2145,7 @@ function containerPlugin(md3, containerOptions = {}) {
|
|
|
2136
2145
|
` : `</div>
|
|
2137
2146
|
`
|
|
2138
2147
|
});
|
|
2139
|
-
const languages = ["zh-CN", "en"];
|
|
2148
|
+
const languages = containerOptions.siteConfig?.languages || ["zh-CN", "en"];
|
|
2140
2149
|
languages.forEach((lang) => {
|
|
2141
2150
|
md3.use(container, lang, {
|
|
2142
2151
|
render: (tokens, idx) => tokens[idx].nesting === 1 ? `<div lang="${lang}">
|
|
@@ -2552,6 +2561,7 @@ async function setupMarkdownPlugins(md3, options, base = "/") {
|
|
|
2552
2561
|
if (mdOptions.preConfig)
|
|
2553
2562
|
mdOptions.preConfig(md3);
|
|
2554
2563
|
md3.use(highlightLinePlugin).use(preWrapperPlugin, { theme, siteConfig }).use(snippetPlugin, options?.userRoot).use(containerPlugin, {
|
|
2564
|
+
siteConfig,
|
|
2555
2565
|
...mdOptions.blocks,
|
|
2556
2566
|
...mdOptions?.container
|
|
2557
2567
|
}).use(cssI18nContainer, {
|
|
@@ -3085,7 +3095,7 @@ var templateConfig = {
|
|
|
3085
3095
|
import fs16 from "fs-extra";
|
|
3086
3096
|
var templateLocales = {
|
|
3087
3097
|
id: "/@valaxyjs/locales",
|
|
3088
|
-
async getContent({ roots }) {
|
|
3098
|
+
async getContent({ roots, config }) {
|
|
3089
3099
|
const imports = [
|
|
3090
3100
|
'import { createDefu } from "defu"',
|
|
3091
3101
|
'const messages = { "zh-CN": {}, en: {} }',
|
|
@@ -3098,7 +3108,7 @@ var templateLocales = {
|
|
|
3098
3108
|
})
|
|
3099
3109
|
`
|
|
3100
3110
|
];
|
|
3101
|
-
const languages = ["zh-CN", "en"];
|
|
3111
|
+
const languages = config.siteConfig.languages || ["zh-CN", "en"];
|
|
3102
3112
|
roots.forEach((root, i) => {
|
|
3103
3113
|
languages.forEach((lang) => {
|
|
3104
3114
|
const langYml = `${root}/locales/${lang}.yml`;
|
|
@@ -4060,7 +4070,7 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
|
|
|
4060
4070
|
console.log();
|
|
4061
4071
|
}
|
|
4062
4072
|
}
|
|
4063
|
-
const
|
|
4073
|
+
const builtinCustomIcon = {
|
|
4064
4074
|
nodejs: "vscode-icons:file-type-node",
|
|
4065
4075
|
playwright: "vscode-icons:file-type-playwright",
|
|
4066
4076
|
typedoc: "vscode-icons:file-type-typedoc",
|
|
@@ -4068,10 +4078,13 @@ async function ViteValaxyPlugins(valaxyApp, serverOptions = {}) {
|
|
|
4068
4078
|
};
|
|
4069
4079
|
plugins.push(
|
|
4070
4080
|
groupIconVitePlugin({
|
|
4071
|
-
customIcon
|
|
4072
|
-
|
|
4081
|
+
customIcon: {
|
|
4082
|
+
...builtinCustomIcon,
|
|
4083
|
+
...valaxyConfig.groupIcons?.customIcon
|
|
4084
|
+
},
|
|
4073
4085
|
defaultLabels: [
|
|
4074
4086
|
...valaxyConfig.groupIcons?.defaultLabels || [],
|
|
4087
|
+
...Object.keys(builtinCustomIcon),
|
|
4075
4088
|
...Object.keys(valaxyConfig.groupIcons?.customIcon || {})
|
|
4076
4089
|
]
|
|
4077
4090
|
})
|
|
@@ -4805,6 +4818,7 @@ export {
|
|
|
4805
4818
|
isExternal,
|
|
4806
4819
|
isPath,
|
|
4807
4820
|
transformObject,
|
|
4821
|
+
$t,
|
|
4808
4822
|
isInstalledGlobally,
|
|
4809
4823
|
resolveImportUrl,
|
|
4810
4824
|
toAtFS,
|
package/dist/node/cli/index.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -653,6 +653,16 @@ declare function isPath(name: string): boolean;
|
|
|
653
653
|
*/
|
|
654
654
|
declare function transformObject(obj: any): string;
|
|
655
655
|
|
|
656
|
+
/**
|
|
657
|
+
* @experimental 试验性
|
|
658
|
+
* @see https://github.com/YunYouJun/valaxy/issues/566
|
|
659
|
+
* @param key
|
|
660
|
+
*
|
|
661
|
+
* 声明这是一个使用国际化的 key
|
|
662
|
+
* 从 locales/ 目录中获取对应的翻译
|
|
663
|
+
*/
|
|
664
|
+
declare function $t(key: string): string;
|
|
665
|
+
|
|
656
666
|
declare const isInstalledGlobally: {
|
|
657
667
|
value?: boolean;
|
|
658
668
|
};
|
|
@@ -668,4 +678,4 @@ declare function toAtFS(path: string): string;
|
|
|
668
678
|
declare function resolveImportPath(importName: string, ensure?: true): Promise<string>;
|
|
669
679
|
declare function resolveImportPath(importName: string, ensure?: boolean): Promise<string | undefined>;
|
|
670
680
|
|
|
671
|
-
export { ALL_ROUTE, EXCERPT_SEPARATOR, type HookResult, type LoadConfigFromFileOptions, PATHNAME_PROTOCOL_RE, type ResolvedConfig, type ResolvedValaxyOptions, type UnoSetup, type UserInputConfig, type UserValaxyNodeConfig, type ValaxyAddonExport, type ValaxyAddonFn, type ValaxyAddonLike, type ValaxyAddonResolver, type ValaxyAddons, type ValaxyApp, type ValaxyConfigExport, type ValaxyConfigExtendKey, type ValaxyConfigFn, type ValaxyEntryOptions, type ValaxyExtendConfig, type ValaxyHooks, type ValaxyNode, type ValaxyNodeConfig, type ValaxyPickConfig, type ValaxyServerOptions, type ValaxyTheme, ViteValaxyPlugins, build, createServer, createValaxyPlugin, customElements, defaultSiteConfig, defaultValaxyConfig, defaultViteConfig, defineAddon, defineConfig, defineSiteConfig, defineTheme, defineUnoSetup, defineValaxyAddon, defineValaxyConfig, defineValaxyTheme, generateClientRedirects, getGitTimestamp, getIndexHtml, getServerInfoText, isExternal, isInstalledGlobally, isPath, loadConfig, loadConfigFromFile, mergeValaxyConfig, mergeViteConfigs, postProcessForSSG, processValaxyOptions, resolveAddonsConfig, resolveImportPath, resolveImportUrl, resolveOptions, resolveSiteConfig, resolveSiteConfigFromRoot, resolveThemeConfigFromRoot, resolveThemeValaxyConfig, resolveUserThemeConfig, resolveValaxyConfig, resolveValaxyConfigFromRoot, ssgBuild, toAtFS, transformObject };
|
|
681
|
+
export { $t, ALL_ROUTE, EXCERPT_SEPARATOR, type HookResult, type LoadConfigFromFileOptions, PATHNAME_PROTOCOL_RE, type ResolvedConfig, type ResolvedValaxyOptions, type UnoSetup, type UserInputConfig, type UserValaxyNodeConfig, type ValaxyAddonExport, type ValaxyAddonFn, type ValaxyAddonLike, type ValaxyAddonResolver, type ValaxyAddons, type ValaxyApp, type ValaxyConfigExport, type ValaxyConfigExtendKey, type ValaxyConfigFn, type ValaxyEntryOptions, type ValaxyExtendConfig, type ValaxyHooks, type ValaxyNode, type ValaxyNodeConfig, type ValaxyPickConfig, type ValaxyServerOptions, type ValaxyTheme, ViteValaxyPlugins, build, createServer, createValaxyPlugin, customElements, defaultSiteConfig, defaultValaxyConfig, defaultViteConfig, defineAddon, defineConfig, defineSiteConfig, defineTheme, defineUnoSetup, defineValaxyAddon, defineValaxyConfig, defineValaxyTheme, generateClientRedirects, getGitTimestamp, getIndexHtml, getServerInfoText, isExternal, isInstalledGlobally, isPath, loadConfig, loadConfigFromFile, mergeValaxyConfig, mergeViteConfigs, postProcessForSSG, processValaxyOptions, resolveAddonsConfig, resolveImportPath, resolveImportUrl, resolveOptions, resolveSiteConfig, resolveSiteConfigFromRoot, resolveThemeConfigFromRoot, resolveThemeValaxyConfig, resolveUserThemeConfig, resolveValaxyConfig, resolveValaxyConfigFromRoot, ssgBuild, toAtFS, transformObject };
|
package/dist/node/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
$t,
|
|
2
3
|
ALL_ROUTE,
|
|
3
4
|
EXCERPT_SEPARATOR,
|
|
4
5
|
PATHNAME_PROTOCOL_RE,
|
|
@@ -49,8 +50,9 @@ import {
|
|
|
49
50
|
startValaxyDev,
|
|
50
51
|
toAtFS,
|
|
51
52
|
transformObject
|
|
52
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-VNLGPNVS.js";
|
|
53
54
|
export {
|
|
55
|
+
$t,
|
|
54
56
|
ALL_ROUTE,
|
|
55
57
|
EXCERPT_SEPARATOR,
|
|
56
58
|
PATHNAME_PROTOCOL_RE,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valaxy",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"description": "📄 Vite & Vue powered static blog generator.",
|
|
6
6
|
"author": {
|
|
7
7
|
"email": "me@yunyoujun.cn",
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
"vue-i18n": "^11.1.9",
|
|
133
133
|
"vue-router": "^4.5.1",
|
|
134
134
|
"yargs": "^18.0.0",
|
|
135
|
-
"@valaxyjs/devtools": "0.
|
|
136
|
-
"@valaxyjs/utils": "0.
|
|
135
|
+
"@valaxyjs/devtools": "0.25.0",
|
|
136
|
+
"@valaxyjs/utils": "0.25.0"
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
139
139
|
"@mdit-vue/plugin-component": "^2.1.4",
|