@vigilkids/cms-nuxt 0.4.0 → 0.5.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/CHANGELOG.md +12 -0
- package/README.md +2 -2
- package/dist/module.json +1 -1
- package/dist/runtime/composables/useBlogSeo.d.ts +16 -0
- package/dist/runtime/composables/useBlogSeo.d.ts.map +1 -1
- package/dist/runtime/composables/useBlogSeo.js +99 -13
- package/dist/runtime/composables/useCmsCategories.d.ts +111 -1
- package/dist/runtime/composables/useCmsCategories.d.ts.map +1 -1
- package/dist/runtime/composables/useCmsCategories.js +13 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.5.0] - 2026-06-03
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added `useLocalizedResourceSeo()` for locale-aware CMS resource metadata, canonical links, Open Graph tags, and Twitter Card tags.
|
|
13
|
+
- Added category metadata exposure in `useCmsCategories()` for taxonomy landing pages.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- `useBlogSeo()` now delegates to the shared localized resource SEO pipeline.
|
|
18
|
+
- Updated peer dependency to `@vigilkids/cms-client ^0.3.0`.
|
|
19
|
+
|
|
8
20
|
## [0.4.0] - 2026-06-03
|
|
9
21
|
|
|
10
22
|
### Added
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ pnpm add @vigilkids/cms-nuxt @vigilkids/cms-client
|
|
|
13
13
|
## Peer Dependencies
|
|
14
14
|
|
|
15
15
|
- `nuxt >=3.15.0`
|
|
16
|
-
- `@vigilkids/cms-client ^0.
|
|
16
|
+
- `@vigilkids/cms-client ^0.3.0`
|
|
17
17
|
- `@nuxtjs/sitemap` is optional and only required when `cms.sitemap.enabled` is `true`
|
|
18
18
|
|
|
19
19
|
## Module Setup
|
|
@@ -265,7 +265,7 @@ All runtime composables are auto-imported.
|
|
|
265
265
|
## Compatibility
|
|
266
266
|
|
|
267
267
|
- Nuxt `>=3.15.0`
|
|
268
|
-
- `@vigilkids/cms-client ^0.
|
|
268
|
+
- `@vigilkids/cms-client ^0.3.0`
|
|
269
269
|
- Vue runtime supplied by Nuxt
|
|
270
270
|
- Node.js version should satisfy the consuming Nuxt application's runtime requirements
|
|
271
271
|
|
package/dist/module.json
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import type { LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedTwitterMetaMap } from '@vigilkids/cms-client/types';
|
|
1
2
|
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export interface UseLocalizedResourceSeoOptions {
|
|
4
|
+
locale: MaybeRefOrGetter<string>;
|
|
5
|
+
fallbackTitle: MaybeRefOrGetter<string>;
|
|
6
|
+
fallbackDescription?: MaybeRefOrGetter<string | null | undefined>;
|
|
7
|
+
fallbackImage?: MaybeRefOrGetter<string | null | undefined>;
|
|
8
|
+
fallbackLocale?: MaybeRefOrGetter<string | null | undefined>;
|
|
9
|
+
seoMeta?: MaybeRefOrGetter<LocalizedSeoMetaMap | undefined>;
|
|
10
|
+
ogMeta?: MaybeRefOrGetter<LocalizedOgMetaMap | undefined>;
|
|
11
|
+
twitterMeta?: MaybeRefOrGetter<LocalizedTwitterMetaMap | undefined>;
|
|
12
|
+
defaultOgType?: MaybeRefOrGetter<string | null | undefined>;
|
|
13
|
+
robots?: MaybeRefOrGetter<string | null | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/** 本地化资源 SEO 元信息 */
|
|
16
|
+
export declare function useLocalizedResourceSeo(options: UseLocalizedResourceSeoOptions): void;
|
|
2
17
|
/** 博客列表页 SEO */
|
|
3
18
|
export declare function useBlogSeo(options: {
|
|
4
19
|
title: MaybeRefOrGetter<string>;
|
|
5
20
|
description?: MaybeRefOrGetter<string>;
|
|
6
21
|
image?: MaybeRefOrGetter<string | undefined>;
|
|
22
|
+
locale?: MaybeRefOrGetter<string>;
|
|
7
23
|
noindex?: boolean;
|
|
8
24
|
}): void;
|
|
9
25
|
//# sourceMappingURL=useBlogSeo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBlogSeo.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useBlogSeo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAI3C,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACtC,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,
|
|
1
|
+
{"version":3,"file":"useBlogSeo.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useBlogSeo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAI3C,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAChC,aAAa,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACvC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IACjE,aAAa,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC3D,cAAc,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC5D,OAAO,CAAC,EAAE,gBAAgB,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAA;IAC3D,MAAM,CAAC,EAAE,gBAAgB,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAA;IACzD,WAAW,CAAC,EAAE,gBAAgB,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAA;IACnE,aAAa,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC3D,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;CACrD;AAoED,oBAAoB;AACpB,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B,QAwD9E;AAED,gBAAgB;AAChB,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC/B,WAAW,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACtC,KAAK,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5C,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,QASA"}
|
|
@@ -1,16 +1,102 @@
|
|
|
1
|
-
import { useSeoMeta } from "#imports";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { useHead, useSeoMeta } from "#imports";
|
|
2
|
+
import { computed, toValue } from "vue";
|
|
3
|
+
const OPEN_GRAPH_TYPES = /* @__PURE__ */ new Set([
|
|
4
|
+
"article",
|
|
5
|
+
"book",
|
|
6
|
+
"music.album",
|
|
7
|
+
"music.playlist",
|
|
8
|
+
"music.radio_status",
|
|
9
|
+
"music.song",
|
|
10
|
+
"profile",
|
|
11
|
+
"video.episode",
|
|
12
|
+
"video.movie",
|
|
13
|
+
"video.other",
|
|
14
|
+
"video.tv_show",
|
|
15
|
+
"website"
|
|
16
|
+
]);
|
|
17
|
+
const TWITTER_CARDS = /* @__PURE__ */ new Set(["app", "player", "summary", "summary_large_image"]);
|
|
18
|
+
function present(value) {
|
|
19
|
+
const normalized = value?.trim();
|
|
20
|
+
return normalized || void 0;
|
|
21
|
+
}
|
|
22
|
+
function normalizeOpenGraphType(value) {
|
|
23
|
+
const normalized = present(value);
|
|
24
|
+
if (!normalized) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
return OPEN_GRAPH_TYPES.has(normalized) ? normalized : void 0;
|
|
28
|
+
}
|
|
29
|
+
function normalizeTwitterCard(value) {
|
|
30
|
+
const normalized = present(value);
|
|
31
|
+
if (!normalized) {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
return TWITTER_CARDS.has(normalized) ? normalized : void 0;
|
|
35
|
+
}
|
|
36
|
+
function localizedEntry(value, locale, fallbackLocale) {
|
|
37
|
+
let fallbackEntry;
|
|
38
|
+
if (fallbackLocale) {
|
|
39
|
+
fallbackEntry = value?.[fallbackLocale];
|
|
40
|
+
}
|
|
41
|
+
return value?.[locale] ?? fallbackEntry ?? Object.values(value ?? {})[0];
|
|
42
|
+
}
|
|
43
|
+
export function useLocalizedResourceSeo(options) {
|
|
44
|
+
const locale = computed(() => toValue(options.locale));
|
|
45
|
+
const fallbackLocale = computed(() => toValue(options.fallbackLocale));
|
|
46
|
+
const seoMeta = computed(
|
|
47
|
+
() => localizedEntry(toValue(options.seoMeta), locale.value, fallbackLocale.value)
|
|
48
|
+
);
|
|
49
|
+
const ogMeta = computed(
|
|
50
|
+
() => localizedEntry(toValue(options.ogMeta), locale.value, fallbackLocale.value)
|
|
51
|
+
);
|
|
52
|
+
const twitterMeta = computed(
|
|
53
|
+
() => localizedEntry(toValue(options.twitterMeta), locale.value, fallbackLocale.value)
|
|
54
|
+
);
|
|
55
|
+
const fallbackTitle = computed(() => toValue(options.fallbackTitle));
|
|
56
|
+
const fallbackDescription = computed(() => toValue(options.fallbackDescription) ?? "");
|
|
57
|
+
const fallbackImage = computed(() => present(toValue(options.fallbackImage)));
|
|
58
|
+
const resolvedTitle = computed(() => present(seoMeta.value?.title) ?? fallbackTitle.value);
|
|
59
|
+
const resolvedDescription = computed(
|
|
60
|
+
() => present(seoMeta.value?.description) ?? fallbackDescription.value
|
|
61
|
+
);
|
|
62
|
+
const resolvedImage = computed(
|
|
63
|
+
() => present(ogMeta.value?.image) ?? present(twitterMeta.value?.image) ?? fallbackImage.value
|
|
64
|
+
);
|
|
65
|
+
const resolvedOgType = computed(
|
|
66
|
+
() => normalizeOpenGraphType(ogMeta.value?.type) ?? normalizeOpenGraphType(toValue(options.defaultOgType)) ?? "website"
|
|
67
|
+
);
|
|
68
|
+
const resolvedTwitterCard = computed(
|
|
69
|
+
() => normalizeTwitterCard(twitterMeta.value?.card) ?? (resolvedImage.value ? "summary_large_image" : void 0)
|
|
70
|
+
);
|
|
7
71
|
useSeoMeta({
|
|
8
|
-
title: () =>
|
|
9
|
-
description: () =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
72
|
+
title: () => resolvedTitle.value,
|
|
73
|
+
description: () => resolvedDescription.value,
|
|
74
|
+
keywords: () => present(seoMeta.value?.keywords),
|
|
75
|
+
robots: () => present(toValue(options.robots)) ?? present(seoMeta.value?.robots),
|
|
76
|
+
ogTitle: () => present(ogMeta.value?.title) ?? resolvedTitle.value,
|
|
77
|
+
ogDescription: () => present(ogMeta.value?.description) ?? resolvedDescription.value,
|
|
78
|
+
ogImage: () => resolvedImage.value,
|
|
79
|
+
ogUrl: () => present(ogMeta.value?.url),
|
|
80
|
+
ogType: () => resolvedOgType.value,
|
|
81
|
+
twitterCard: () => resolvedTwitterCard.value,
|
|
82
|
+
twitterTitle: () => present(twitterMeta.value?.title) ?? resolvedTitle.value,
|
|
83
|
+
twitterDescription: () => present(twitterMeta.value?.description) ?? resolvedDescription.value,
|
|
84
|
+
twitterImage: () => resolvedImage.value
|
|
85
|
+
});
|
|
86
|
+
useHead({
|
|
87
|
+
link: () => {
|
|
88
|
+
const canonicalUrl = present(seoMeta.value?.canonical_url);
|
|
89
|
+
return canonicalUrl ? [{ rel: "canonical", href: canonicalUrl }] : [];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function useBlogSeo(options) {
|
|
94
|
+
useLocalizedResourceSeo({
|
|
95
|
+
locale: options.locale ?? "",
|
|
96
|
+
fallbackTitle: options.title,
|
|
97
|
+
fallbackDescription: options.description ?? "",
|
|
98
|
+
fallbackImage: options.image,
|
|
99
|
+
defaultOgType: "website",
|
|
100
|
+
robots: options.noindex ? "noindex, follow" : void 0
|
|
15
101
|
});
|
|
16
102
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type { CategoryNode } from '@vigilkids/cms-client/types';
|
|
1
|
+
import type { CategoryNode, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedTwitterMetaMap, OgMeta, SeoMeta, TwitterMeta } from '@vigilkids/cms-client/types';
|
|
2
2
|
export interface CmsResolvedCategory {
|
|
3
3
|
id: number;
|
|
4
4
|
slug: string;
|
|
5
5
|
name: string;
|
|
6
6
|
description?: string;
|
|
7
|
+
seoMeta?: Partial<SeoMeta>;
|
|
8
|
+
ogMeta?: Partial<OgMeta>;
|
|
9
|
+
twitterMeta?: Partial<TwitterMeta>;
|
|
10
|
+
localizedSeoMeta?: LocalizedSeoMetaMap;
|
|
11
|
+
localizedOgMeta?: LocalizedOgMetaMap;
|
|
12
|
+
localizedTwitterMeta?: LocalizedTwitterMetaMap;
|
|
7
13
|
articleCount: number;
|
|
8
14
|
}
|
|
9
15
|
/** CMS 分类预加载数据和路由工具 */
|
|
@@ -17,6 +23,32 @@ export declare function useCmsCategories(): {
|
|
|
17
23
|
readonly description: {
|
|
18
24
|
readonly [x: string]: string;
|
|
19
25
|
};
|
|
26
|
+
readonly seo_meta?: {
|
|
27
|
+
readonly [x: string]: {
|
|
28
|
+
readonly title?: string | null | undefined;
|
|
29
|
+
readonly description?: string | null | undefined;
|
|
30
|
+
readonly keywords?: string | null | undefined;
|
|
31
|
+
readonly robots?: string | null | undefined;
|
|
32
|
+
readonly canonical_url?: string | null | undefined;
|
|
33
|
+
};
|
|
34
|
+
} | undefined;
|
|
35
|
+
readonly og_meta?: {
|
|
36
|
+
readonly [x: string]: {
|
|
37
|
+
readonly title?: string | null | undefined;
|
|
38
|
+
readonly description?: string | null | undefined;
|
|
39
|
+
readonly image?: string | null | undefined;
|
|
40
|
+
readonly url?: string | null | undefined;
|
|
41
|
+
readonly type?: string | null | undefined;
|
|
42
|
+
};
|
|
43
|
+
} | undefined;
|
|
44
|
+
readonly twitter_meta?: {
|
|
45
|
+
readonly [x: string]: {
|
|
46
|
+
readonly card?: string | null | undefined;
|
|
47
|
+
readonly title?: string | null | undefined;
|
|
48
|
+
readonly description?: string | null | undefined;
|
|
49
|
+
readonly image?: string | null | undefined;
|
|
50
|
+
};
|
|
51
|
+
} | undefined;
|
|
20
52
|
readonly article_count: number;
|
|
21
53
|
readonly article_counts?: {
|
|
22
54
|
readonly [x: string]: number;
|
|
@@ -31,6 +63,32 @@ export declare function useCmsCategories(): {
|
|
|
31
63
|
readonly description: {
|
|
32
64
|
readonly [x: string]: string;
|
|
33
65
|
};
|
|
66
|
+
readonly seo_meta?: {
|
|
67
|
+
readonly [x: string]: {
|
|
68
|
+
readonly title?: string | null | undefined;
|
|
69
|
+
readonly description?: string | null | undefined;
|
|
70
|
+
readonly keywords?: string | null | undefined;
|
|
71
|
+
readonly robots?: string | null | undefined;
|
|
72
|
+
readonly canonical_url?: string | null | undefined;
|
|
73
|
+
};
|
|
74
|
+
} | undefined;
|
|
75
|
+
readonly og_meta?: {
|
|
76
|
+
readonly [x: string]: {
|
|
77
|
+
readonly title?: string | null | undefined;
|
|
78
|
+
readonly description?: string | null | undefined;
|
|
79
|
+
readonly image?: string | null | undefined;
|
|
80
|
+
readonly url?: string | null | undefined;
|
|
81
|
+
readonly type?: string | null | undefined;
|
|
82
|
+
};
|
|
83
|
+
} | undefined;
|
|
84
|
+
readonly twitter_meta?: {
|
|
85
|
+
readonly [x: string]: {
|
|
86
|
+
readonly card?: string | null | undefined;
|
|
87
|
+
readonly title?: string | null | undefined;
|
|
88
|
+
readonly description?: string | null | undefined;
|
|
89
|
+
readonly image?: string | null | undefined;
|
|
90
|
+
};
|
|
91
|
+
} | undefined;
|
|
34
92
|
readonly article_count: number;
|
|
35
93
|
readonly article_counts?: {
|
|
36
94
|
readonly [x: string]: number;
|
|
@@ -46,6 +104,32 @@ export declare function useCmsCategories(): {
|
|
|
46
104
|
readonly description: {
|
|
47
105
|
readonly [x: string]: string;
|
|
48
106
|
};
|
|
107
|
+
readonly seo_meta?: {
|
|
108
|
+
readonly [x: string]: {
|
|
109
|
+
readonly title?: string | null | undefined;
|
|
110
|
+
readonly description?: string | null | undefined;
|
|
111
|
+
readonly keywords?: string | null | undefined;
|
|
112
|
+
readonly robots?: string | null | undefined;
|
|
113
|
+
readonly canonical_url?: string | null | undefined;
|
|
114
|
+
};
|
|
115
|
+
} | undefined;
|
|
116
|
+
readonly og_meta?: {
|
|
117
|
+
readonly [x: string]: {
|
|
118
|
+
readonly title?: string | null | undefined;
|
|
119
|
+
readonly description?: string | null | undefined;
|
|
120
|
+
readonly image?: string | null | undefined;
|
|
121
|
+
readonly url?: string | null | undefined;
|
|
122
|
+
readonly type?: string | null | undefined;
|
|
123
|
+
};
|
|
124
|
+
} | undefined;
|
|
125
|
+
readonly twitter_meta?: {
|
|
126
|
+
readonly [x: string]: {
|
|
127
|
+
readonly card?: string | null | undefined;
|
|
128
|
+
readonly title?: string | null | undefined;
|
|
129
|
+
readonly description?: string | null | undefined;
|
|
130
|
+
readonly image?: string | null | undefined;
|
|
131
|
+
};
|
|
132
|
+
} | undefined;
|
|
49
133
|
readonly article_count: number;
|
|
50
134
|
readonly article_counts?: {
|
|
51
135
|
readonly [x: string]: number;
|
|
@@ -60,6 +144,32 @@ export declare function useCmsCategories(): {
|
|
|
60
144
|
readonly description: {
|
|
61
145
|
readonly [x: string]: string;
|
|
62
146
|
};
|
|
147
|
+
readonly seo_meta?: {
|
|
148
|
+
readonly [x: string]: {
|
|
149
|
+
readonly title?: string | null | undefined;
|
|
150
|
+
readonly description?: string | null | undefined;
|
|
151
|
+
readonly keywords?: string | null | undefined;
|
|
152
|
+
readonly robots?: string | null | undefined;
|
|
153
|
+
readonly canonical_url?: string | null | undefined;
|
|
154
|
+
};
|
|
155
|
+
} | undefined;
|
|
156
|
+
readonly og_meta?: {
|
|
157
|
+
readonly [x: string]: {
|
|
158
|
+
readonly title?: string | null | undefined;
|
|
159
|
+
readonly description?: string | null | undefined;
|
|
160
|
+
readonly image?: string | null | undefined;
|
|
161
|
+
readonly url?: string | null | undefined;
|
|
162
|
+
readonly type?: string | null | undefined;
|
|
163
|
+
};
|
|
164
|
+
} | undefined;
|
|
165
|
+
readonly twitter_meta?: {
|
|
166
|
+
readonly [x: string]: {
|
|
167
|
+
readonly card?: string | null | undefined;
|
|
168
|
+
readonly title?: string | null | undefined;
|
|
169
|
+
readonly description?: string | null | undefined;
|
|
170
|
+
readonly image?: string | null | undefined;
|
|
171
|
+
};
|
|
172
|
+
} | undefined;
|
|
63
173
|
readonly article_count: number;
|
|
64
174
|
readonly article_counts?: {
|
|
65
175
|
readonly [x: string]: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCmsCategories.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsCategories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useCmsCategories.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsCategories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,MAAM,EACN,OAAO,EACP,WAAW,EACZ,MAAM,6BAA6B,CAAA;AAKpC,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAClC,gBAAgB,CAAC,EAAE,mBAAmB,CAAA;IACtC,eAAe,CAAC,EAAE,kBAAkB,CAAA;IACpC,oBAAoB,CAAC,EAAE,uBAAuB,CAAA;IAC9C,YAAY,EAAE,MAAM,CAAA;CACrB;AA+BD,uBAAuB;AACvB,wBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAcK,YAAY,sBAAkB,mBAAmB;gCAwBjD,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC;;2BAJ/B,MAAM;uBAJV,MAAM;EA4BjC"}
|
|
@@ -2,17 +2,22 @@ import { useRuntimeConfig } from "#imports";
|
|
|
2
2
|
import { computed, readonly } from "vue";
|
|
3
3
|
import { useCmsRoutes } from "./useCmsRoutes.js";
|
|
4
4
|
function localizedText(value, locale, fallback) {
|
|
5
|
-
if (!value)
|
|
5
|
+
if (!value) {
|
|
6
6
|
return fallback;
|
|
7
|
+
}
|
|
7
8
|
return value[locale] || value.en || Object.values(value)[0] || fallback;
|
|
8
9
|
}
|
|
10
|
+
function localizedEntry(value, locale) {
|
|
11
|
+
return value?.[locale] ?? value?.en ?? Object.values(value ?? {})[0];
|
|
12
|
+
}
|
|
9
13
|
function flattenCategories(categories) {
|
|
10
14
|
const result = [];
|
|
11
15
|
function walk(nodes) {
|
|
12
16
|
for (const node of nodes) {
|
|
13
17
|
result.push(node);
|
|
14
|
-
if (node.children?.length)
|
|
18
|
+
if (node.children?.length) {
|
|
15
19
|
walk(node.children);
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
walk(categories);
|
|
@@ -30,6 +35,12 @@ export function useCmsCategories() {
|
|
|
30
35
|
slug: category.slug,
|
|
31
36
|
name: localizedText(category.name, locale, category.slug),
|
|
32
37
|
description: localizedText(category.description, locale, ""),
|
|
38
|
+
seoMeta: localizedEntry(category.seo_meta, locale),
|
|
39
|
+
ogMeta: localizedEntry(category.og_meta, locale),
|
|
40
|
+
twitterMeta: localizedEntry(category.twitter_meta, locale),
|
|
41
|
+
localizedSeoMeta: category.seo_meta,
|
|
42
|
+
localizedOgMeta: category.og_meta,
|
|
43
|
+
localizedTwitterMeta: category.twitter_meta,
|
|
33
44
|
articleCount: category.article_count
|
|
34
45
|
};
|
|
35
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vigilkids/cms-nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Nuxt 3 module for OnEx CMS — composables, server routes, middleware, sitemap",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.mjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vue": "^3.4.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@vigilkids/cms-client": "^0.
|
|
47
|
+
"@vigilkids/cms-client": "^0.3.0",
|
|
48
48
|
"nuxt": ">=3.15.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|