valaxy 0.28.0-beta.6 → 0.28.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/.exclude/ValaxyDebug.vue +176 -0
- package/client/components/ValaxyOpenInEditor.vue +53 -0
- package/client/composables/app/useValaxyApp.ts +1 -7
- package/client/composables/categories.ts +3 -56
- package/client/composables/category-utils.ts +50 -0
- package/client/composables/index.ts +1 -0
- package/client/composables/locale.ts +68 -9
- package/client/composables/outline/anchor.ts +1 -1
- package/client/composables/post/index.ts +6 -3
- package/client/composables/tags.ts +0 -5
- package/client/modules/components.ts +7 -0
- package/client/modules/valaxy.ts +28 -3
- package/dist/node/cli/index.mjs +1 -1
- package/dist/node/index.d.mts +31 -1
- package/dist/node/index.mjs +1 -1
- package/dist/shared/{valaxy.JIuR8V4d.d.mts → valaxy.6MW2qn5T.d.mts} +12 -4
- package/dist/shared/{valaxy.BVsZMcdc.mjs → valaxy.DQ6HsU2J.mjs} +317 -15
- package/dist/types/index.d.mts +2 -2
- package/package.json +11 -12
- package/shared/node/i18n.ts +4 -4
- package/shared/utils/i18n.ts +55 -0
- package/types/config.ts +0 -4
- package/types/frontmatter/page.ts +12 -0
package/shared/utils/i18n.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { LOCALE_PREFIX } from '../constants'
|
|
2
|
+
|
|
3
|
+
export type TaxonomyNamespace = 'tag' | 'category'
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* translate object
|
|
3
7
|
*
|
|
@@ -15,3 +19,54 @@ export function tObject<T = string>(data: string | Record<string, T>, lang: stri
|
|
|
15
19
|
}
|
|
16
20
|
return data
|
|
17
21
|
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether the value is an explicit locale key like `$locale:tag.notes`.
|
|
25
|
+
*/
|
|
26
|
+
export function isLocaleKey(value: string): boolean {
|
|
27
|
+
return value.startsWith(LOCALE_PREFIX)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Strip `$locale:` prefix when present.
|
|
32
|
+
*/
|
|
33
|
+
export function stripLocalePrefix(value: string): string {
|
|
34
|
+
return isLocaleKey(value) ? value.slice(LOCALE_PREFIX.length) : value
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a nested locale message value by dot-separated key.
|
|
39
|
+
*/
|
|
40
|
+
export function getLocaleMessageValue(messages: Record<string, any> | undefined, key: string): any {
|
|
41
|
+
return key.split('.').reduce<any>((result, part) => result?.[part], messages)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether a locale message exists for the given key.
|
|
46
|
+
*/
|
|
47
|
+
export function hasLocaleMessage(messages: Record<string, any> | undefined, key: string): boolean {
|
|
48
|
+
return getLocaleMessageValue(messages, key) !== undefined
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the effective locale key for a taxonomy term.
|
|
53
|
+
*
|
|
54
|
+
* - `$locale:tag.notes` -> `tag.notes` (explicit locale key)
|
|
55
|
+
* - `notes` in `tag` namespace -> `tag.notes`
|
|
56
|
+
*/
|
|
57
|
+
export function resolveTaxonomyLocaleKey(namespace: TaxonomyNamespace, rawValue: string): {
|
|
58
|
+
localeKey: string
|
|
59
|
+
isExplicitLocaleKey: boolean
|
|
60
|
+
} {
|
|
61
|
+
if (isLocaleKey(rawValue)) {
|
|
62
|
+
return {
|
|
63
|
+
localeKey: stripLocalePrefix(rawValue),
|
|
64
|
+
isExplicitLocaleKey: true,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
localeKey: `${namespace}.${rawValue}`,
|
|
70
|
+
isExplicitLocaleKey: false,
|
|
71
|
+
}
|
|
72
|
+
}
|
package/types/config.ts
CHANGED
|
@@ -172,10 +172,6 @@ export interface SiteConfig {
|
|
|
172
172
|
* @zh 是否启用
|
|
173
173
|
*/
|
|
174
174
|
enable: boolean
|
|
175
|
-
/**
|
|
176
|
-
* @deprecated will be deprecated, use search.provider instead
|
|
177
|
-
*/
|
|
178
|
-
type?: SiteConfig['search']['provider']
|
|
179
175
|
/**
|
|
180
176
|
* Search Type
|
|
181
177
|
* - algolia: Algolia Search
|
|
@@ -109,6 +109,18 @@ export interface PageFrontMatter extends BaseFrontMatter {
|
|
|
109
109
|
* @description 封面图片
|
|
110
110
|
*/
|
|
111
111
|
cover: string
|
|
112
|
+
/**
|
|
113
|
+
* @description:en-US Open Graph image for SEO
|
|
114
|
+
* @description:zh-CN Open Graph 图片,用于 SEO
|
|
115
|
+
*/
|
|
116
|
+
ogImage: string
|
|
117
|
+
/**
|
|
118
|
+
* @protected
|
|
119
|
+
* @tutorial ⚠️ DO NOT SET MANUALLY (auto-extracted from markdown content)
|
|
120
|
+
* @description:en-US First image URL extracted from markdown content
|
|
121
|
+
* @description:zh-CN 从 Markdown 内容中自动提取的第一张图片 URL
|
|
122
|
+
*/
|
|
123
|
+
firstImage: string
|
|
112
124
|
/**
|
|
113
125
|
* display toc
|
|
114
126
|
* @description 是否显示目录
|