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.
@@ -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 是否显示目录