@vigilkids/cms-nuxt 0.3.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 +111 -0
- package/README.md +239 -22
- package/dist/module.d.mts +37 -2
- package/dist/module.d.ts +5 -44
- package/dist/module.d.ts.map +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +91 -5
- package/dist/runtime/composables/useArticle.d.ts +16 -0
- package/dist/runtime/composables/useArticle.d.ts.map +1 -0
- package/dist/runtime/composables/useArticleList.d.ts +11 -0
- package/dist/runtime/composables/useArticleList.d.ts.map +1 -0
- package/dist/runtime/composables/useAuthor.d.ts +10 -0
- package/dist/runtime/composables/useAuthor.d.ts.map +1 -0
- package/dist/runtime/composables/useBlogSeo.d.ts +25 -0
- package/dist/runtime/composables/useBlogSeo.d.ts.map +1 -0
- package/dist/runtime/composables/useBlogSeo.js +99 -13
- package/dist/runtime/composables/useCategories.d.ts +10 -0
- package/dist/runtime/composables/useCategories.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsArticleCollection.d.ts +14 -0
- package/dist/runtime/composables/useCmsArticleCollection.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsArticleCollection.js +16 -0
- package/dist/runtime/composables/useCmsCategories.d.ts +188 -0
- package/dist/runtime/composables/useCmsCategories.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsCategories.js +71 -0
- package/dist/runtime/composables/useCmsClient.d.ts +4 -0
- package/dist/runtime/composables/useCmsClient.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsFetch.d.ts +19 -0
- package/dist/runtime/composables/useCmsFetch.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsFetch.js +20 -0
- package/dist/runtime/composables/useCmsPreview.d.ts +16 -0
- package/dist/runtime/composables/useCmsPreview.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsRoutes.d.ts +7 -0
- package/dist/runtime/composables/useCmsRoutes.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsRoutes.js +10 -0
- package/dist/runtime/composables/useHreflangLinks.d.ts +34 -0
- package/dist/runtime/composables/useHreflangLinks.d.ts.map +1 -0
- package/dist/runtime/composables/useHreflangLinks.js +2 -1
- package/dist/runtime/plugins/preview-init.client.d.ts +4 -0
- package/dist/runtime/plugins/preview-init.client.d.ts.map +1 -0
- package/dist/runtime/server/api/_revalidate.post.d.ts +9 -0
- package/dist/runtime/server/api/_revalidate.post.d.ts.map +1 -0
- package/dist/runtime/server/api/_revalidate.post.js +30 -10
- package/dist/runtime/server/api/articles.get.d.ts +4 -0
- package/dist/runtime/server/api/articles.get.d.ts.map +1 -0
- package/dist/runtime/server/api/articles.get.js +92 -0
- package/dist/runtime/server/api/preview.get.d.ts +4 -0
- package/dist/runtime/server/api/preview.get.d.ts.map +1 -0
- package/dist/runtime/server/api/preview.get.js +47 -12
- package/dist/runtime/server/api/sitemap-urls.get.d.ts +16 -0
- package/dist/runtime/server/api/sitemap-urls.get.d.ts.map +1 -0
- package/dist/runtime/server/api/sitemap-urls.get.js +20 -0
- package/dist/runtime/server/middleware/preview-context.d.ts +14 -0
- package/dist/runtime/server/middleware/preview-context.d.ts.map +1 -0
- package/dist/runtime/server/middleware/redirects.d.ts +4 -0
- package/dist/runtime/server/middleware/redirects.d.ts.map +1 -0
- package/dist/runtime/server/middleware/redirects.js +27 -10
- package/dist/runtime/server/routes/cms-proxy.d.ts +3 -0
- package/dist/runtime/server/routes/cms-proxy.d.ts.map +1 -0
- package/dist/runtime/server/routes/cms-proxy.js +55 -0
- package/dist/runtime/server/utils/cms-client.d.ts +4 -0
- package/dist/runtime/server/utils/cms-client.d.ts.map +1 -0
- package/dist/runtime/server/utils/cms-client.js +14 -7
- package/dist/runtime/sitemap/provider.d.ts +17 -0
- package/dist/runtime/sitemap/provider.d.ts.map +1 -0
- package/dist/runtime/sitemap/provider.js +9 -11
- package/dist/runtime/utils/list.d.ts +2 -0
- package/dist/runtime/utils/list.d.ts.map +1 -0
- package/dist/runtime/utils/routes.d.ts +19 -0
- package/dist/runtime/utils/routes.d.ts.map +1 -0
- package/dist/runtime/utils/routes.js +119 -0
- package/dist/runtime/utils/sitemap.d.ts +20 -0
- package/dist/runtime/utils/sitemap.d.ts.map +1 -0
- package/dist/runtime/utils/sitemap.js +44 -0
- package/dist/types.d.ts +76 -7
- package/dist/types.d.ts.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArticleListItem } from '@vigilkids/cms-client/types';
|
|
2
|
+
import type { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
3
|
+
/** 文章详情 + 自动 SEO */
|
|
4
|
+
export declare function useArticle(slug: MaybeRefOrGetter<string>): {
|
|
5
|
+
article: import("#imports").Ref<import("@vigilkids/cms-client").ArticleDetail | null, import("@vigilkids/cms-client").ArticleDetail | null>;
|
|
6
|
+
relatedArticles: ComputedRef<ArticleListItem[]>;
|
|
7
|
+
status: import("#imports").Ref<string, string>;
|
|
8
|
+
error: import("#imports").Ref<Error | null, Error | null>;
|
|
9
|
+
ready: {
|
|
10
|
+
data: import("#imports").Ref<import("@vigilkids/cms-client").ArticleDetail | null, import("@vigilkids/cms-client").ArticleDetail | null>;
|
|
11
|
+
status: import("#imports").Ref<string>;
|
|
12
|
+
error: import("#imports").Ref<Error | null>;
|
|
13
|
+
refresh: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useArticle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useArticle.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useArticle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAMxD,oBAAoB;AACpB,wBAAgB,UAAU,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC;;qBAoDd,WAAW,CAAC,eAAe,EAAE,CAAC;;;;;;;;;EAKxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ArticleListItem, ArticleListParams, PaginationMeta } from '@vigilkids/cms-client/types';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
/** 文章列表 + 分页 */
|
|
4
|
+
export declare function useArticleList(params: MaybeRefOrGetter<ArticleListParams>): {
|
|
5
|
+
articles: import("vue").ComputedRef<ArticleListItem[]>;
|
|
6
|
+
pagination: import("vue").ComputedRef<PaginationMeta | null>;
|
|
7
|
+
status: import("#imports").Ref<string, string>;
|
|
8
|
+
error: import("#imports").Ref<Error | null, Error | null>;
|
|
9
|
+
refresh: () => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useArticleList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useArticleList.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useArticleList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,cAAc,EACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAK3C,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,CAAC,iBAAiB,CAAC;;;;;;EAczE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArticleListItem, Author } from '@vigilkids/cms-client/types';
|
|
2
|
+
import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
3
|
+
/** 作者详情 + 文章列表 */
|
|
4
|
+
export declare function useAuthor(slug: MaybeRefOrGetter<string>): {
|
|
5
|
+
author: Ref<Author | null>;
|
|
6
|
+
articles: ComputedRef<ArticleListItem[]>;
|
|
7
|
+
status: Ref<string, string>;
|
|
8
|
+
error: Ref<Error | null, Error | null>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useAuthor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAuthor.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useAuthor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAM7D,kBAAkB;AAClB,wBAAgB,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC;YAoBlC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC;cACX,WAAW,CAAC,eAAe,EAAE,CAAC;;;EAI1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedTwitterMetaMap } from '@vigilkids/cms-client/types';
|
|
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;
|
|
17
|
+
/** 博客列表页 SEO */
|
|
18
|
+
export declare function useBlogSeo(options: {
|
|
19
|
+
title: MaybeRefOrGetter<string>;
|
|
20
|
+
description?: MaybeRefOrGetter<string>;
|
|
21
|
+
image?: MaybeRefOrGetter<string | undefined>;
|
|
22
|
+
locale?: MaybeRefOrGetter<string>;
|
|
23
|
+
noindex?: boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
//# sourceMappingURL=useBlogSeo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CategoryNode } from '@vigilkids/cms-client/types';
|
|
2
|
+
/** 分类树 + 工具方法 */
|
|
3
|
+
export declare function useCategories(): {
|
|
4
|
+
categories: import("vue").ComputedRef<CategoryNode[]>;
|
|
5
|
+
flatCategories: import("vue").ComputedRef<CategoryNode[]>;
|
|
6
|
+
findBySlug: (slug: string) => CategoryNode | undefined;
|
|
7
|
+
status: import("#imports").Ref<string, string>;
|
|
8
|
+
error: import("#imports").Ref<Error | null, Error | null>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useCategories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCategories.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCategories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAM/D,iBAAiB;AACjB,wBAAgB,aAAa;;;uBAsBD,MAAM,KAAG,YAAY,GAAG,SAAS;;;EAK5D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ArticleListItem, ArticleListParams, PaginationMeta } from '@vigilkids/cms-client/types';
|
|
2
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
3
|
+
export interface CmsArticleCollectionParams extends ArticleListParams {
|
|
4
|
+
q?: string;
|
|
5
|
+
}
|
|
6
|
+
/** CMS 文章集合查询,统一支持分类、搜索和分页 */
|
|
7
|
+
export declare function useCmsArticleCollection(params: MaybeRefOrGetter<CmsArticleCollectionParams>): {
|
|
8
|
+
articles: import("vue").ComputedRef<ArticleListItem[]>;
|
|
9
|
+
pagination: import("vue").ComputedRef<PaginationMeta | null>;
|
|
10
|
+
status: import("#imports").Ref<string, string>;
|
|
11
|
+
error: import("#imports").Ref<Error | null, Error | null>;
|
|
12
|
+
refresh: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=useCmsArticleCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsArticleCollection.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsArticleCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAa,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAI3C,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACnE,CAAC,CAAC,EAAE,MAAM,CAAA;CACX;AAED,8BAA8B;AAC9B,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,CAAC,0BAA0B,CAAC;;;;;;EAkB3F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useAsyncData, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { computed, toRef } from "vue";
|
|
3
|
+
export function useCmsArticleCollection(params) {
|
|
4
|
+
const resolvedParams = toRef(params);
|
|
5
|
+
const config = useRuntimeConfig();
|
|
6
|
+
const cmsConfig = config.public.cms;
|
|
7
|
+
const endpoint = cmsConfig.content?.articleCollectionPath ?? "/api/cms/articles";
|
|
8
|
+
const { data, status, error, refresh } = useAsyncData(
|
|
9
|
+
`cms-article-collection-${JSON.stringify(resolvedParams.value)}`,
|
|
10
|
+
() => $fetch(endpoint, { params: resolvedParams.value }),
|
|
11
|
+
{ watch: [resolvedParams] }
|
|
12
|
+
);
|
|
13
|
+
const articles = computed(() => data.value?.data ?? []);
|
|
14
|
+
const pagination = computed(() => data.value?.pagination ?? null);
|
|
15
|
+
return { articles, pagination, status, error, refresh };
|
|
16
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { CategoryNode, LocalizedOgMetaMap, LocalizedSeoMetaMap, LocalizedTwitterMetaMap, OgMeta, SeoMeta, TwitterMeta } from '@vigilkids/cms-client/types';
|
|
2
|
+
export interface CmsResolvedCategory {
|
|
3
|
+
id: number;
|
|
4
|
+
slug: string;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
seoMeta?: Partial<SeoMeta>;
|
|
8
|
+
ogMeta?: Partial<OgMeta>;
|
|
9
|
+
twitterMeta?: Partial<TwitterMeta>;
|
|
10
|
+
localizedSeoMeta?: LocalizedSeoMetaMap;
|
|
11
|
+
localizedOgMeta?: LocalizedOgMetaMap;
|
|
12
|
+
localizedTwitterMeta?: LocalizedTwitterMetaMap;
|
|
13
|
+
articleCount: number;
|
|
14
|
+
}
|
|
15
|
+
/** CMS 分类预加载数据和路由工具 */
|
|
16
|
+
export declare function useCmsCategories(): {
|
|
17
|
+
rawCategories: Readonly<import("#imports").Ref<readonly {
|
|
18
|
+
readonly id: number;
|
|
19
|
+
readonly slug: string;
|
|
20
|
+
readonly name: {
|
|
21
|
+
readonly [x: string]: string;
|
|
22
|
+
};
|
|
23
|
+
readonly description: {
|
|
24
|
+
readonly [x: string]: string;
|
|
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;
|
|
52
|
+
readonly article_count: number;
|
|
53
|
+
readonly article_counts?: {
|
|
54
|
+
readonly [x: string]: number;
|
|
55
|
+
} | undefined;
|
|
56
|
+
readonly children?: readonly /*elided*/ any[] | undefined;
|
|
57
|
+
}[], readonly {
|
|
58
|
+
readonly id: number;
|
|
59
|
+
readonly slug: string;
|
|
60
|
+
readonly name: {
|
|
61
|
+
readonly [x: string]: string;
|
|
62
|
+
};
|
|
63
|
+
readonly description: {
|
|
64
|
+
readonly [x: string]: string;
|
|
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;
|
|
92
|
+
readonly article_count: number;
|
|
93
|
+
readonly article_counts?: {
|
|
94
|
+
readonly [x: string]: number;
|
|
95
|
+
} | undefined;
|
|
96
|
+
readonly children?: readonly /*elided*/ any[] | undefined;
|
|
97
|
+
}[]>>;
|
|
98
|
+
flatCategories: Readonly<import("#imports").Ref<readonly {
|
|
99
|
+
readonly id: number;
|
|
100
|
+
readonly slug: string;
|
|
101
|
+
readonly name: {
|
|
102
|
+
readonly [x: string]: string;
|
|
103
|
+
};
|
|
104
|
+
readonly description: {
|
|
105
|
+
readonly [x: string]: string;
|
|
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;
|
|
133
|
+
readonly article_count: number;
|
|
134
|
+
readonly article_counts?: {
|
|
135
|
+
readonly [x: string]: number;
|
|
136
|
+
} | undefined;
|
|
137
|
+
readonly children?: readonly /*elided*/ any[] | undefined;
|
|
138
|
+
}[], readonly {
|
|
139
|
+
readonly id: number;
|
|
140
|
+
readonly slug: string;
|
|
141
|
+
readonly name: {
|
|
142
|
+
readonly [x: string]: string;
|
|
143
|
+
};
|
|
144
|
+
readonly description: {
|
|
145
|
+
readonly [x: string]: string;
|
|
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;
|
|
173
|
+
readonly article_count: number;
|
|
174
|
+
readonly article_counts?: {
|
|
175
|
+
readonly [x: string]: number;
|
|
176
|
+
} | undefined;
|
|
177
|
+
readonly children?: readonly /*elided*/ any[] | undefined;
|
|
178
|
+
}[]>>;
|
|
179
|
+
currentCategories: import("vue").ComputedRef<CmsResolvedCategory[]>;
|
|
180
|
+
lastUpdated: string | undefined;
|
|
181
|
+
buildTime: string | undefined;
|
|
182
|
+
resolveCategory: (category: CategoryNode, locale?: string) => CmsResolvedCategory;
|
|
183
|
+
getCategoryPath: (category: Pick<CategoryNode, "slug">) => string;
|
|
184
|
+
getDisplayCategories: (locale?: string) => CmsResolvedCategory[];
|
|
185
|
+
categoryExists: (slug: string) => boolean;
|
|
186
|
+
findBySlug: (slug: string) => CategoryNode | undefined;
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=useCmsCategories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { computed, readonly } from "vue";
|
|
3
|
+
import { useCmsRoutes } from "./useCmsRoutes.js";
|
|
4
|
+
function localizedText(value, locale, fallback) {
|
|
5
|
+
if (!value) {
|
|
6
|
+
return fallback;
|
|
7
|
+
}
|
|
8
|
+
return value[locale] || value.en || Object.values(value)[0] || fallback;
|
|
9
|
+
}
|
|
10
|
+
function localizedEntry(value, locale) {
|
|
11
|
+
return value?.[locale] ?? value?.en ?? Object.values(value ?? {})[0];
|
|
12
|
+
}
|
|
13
|
+
function flattenCategories(categories) {
|
|
14
|
+
const result = [];
|
|
15
|
+
function walk(nodes) {
|
|
16
|
+
for (const node of nodes) {
|
|
17
|
+
result.push(node);
|
|
18
|
+
if (node.children?.length) {
|
|
19
|
+
walk(node.children);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
walk(categories);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
export function useCmsCategories() {
|
|
27
|
+
const config = useRuntimeConfig();
|
|
28
|
+
const routes = useCmsRoutes();
|
|
29
|
+
const cmsConfig = config.public.cms;
|
|
30
|
+
const rawCategories = computed(() => cmsConfig.categories?.items ?? []);
|
|
31
|
+
const flatCategories = computed(() => flattenCategories(rawCategories.value));
|
|
32
|
+
function resolveCategory(category, locale = "en") {
|
|
33
|
+
return {
|
|
34
|
+
id: category.id,
|
|
35
|
+
slug: category.slug,
|
|
36
|
+
name: localizedText(category.name, locale, category.slug),
|
|
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,
|
|
44
|
+
articleCount: category.article_count
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function findBySlug(slug) {
|
|
48
|
+
return flatCategories.value.find((category) => category.slug === slug);
|
|
49
|
+
}
|
|
50
|
+
function categoryExists(slug) {
|
|
51
|
+
return Boolean(findBySlug(slug));
|
|
52
|
+
}
|
|
53
|
+
function getCategoryPath(category) {
|
|
54
|
+
return routes.build("category", { category_slug: category.slug });
|
|
55
|
+
}
|
|
56
|
+
function getDisplayCategories(locale = "en") {
|
|
57
|
+
return rawCategories.value.map((category) => resolveCategory(category, locale));
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
rawCategories: readonly(rawCategories),
|
|
61
|
+
flatCategories: readonly(flatCategories),
|
|
62
|
+
currentCategories: computed(() => getDisplayCategories()),
|
|
63
|
+
lastUpdated: cmsConfig.categories?.lastUpdated,
|
|
64
|
+
buildTime: cmsConfig.categories?.buildTime,
|
|
65
|
+
resolveCategory,
|
|
66
|
+
getCategoryPath,
|
|
67
|
+
getDisplayCategories,
|
|
68
|
+
categoryExists,
|
|
69
|
+
findBySlug
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsClient.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,+BAA+B;AAC/B,wBAAgB,YAAY,IAAI,SAAS,CAexC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
export interface CmsFetchError {
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
statusMessage?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface CmsFetchResult<T> {
|
|
9
|
+
data: Ref<T | null>;
|
|
10
|
+
error: Ref<CmsFetchError | null>;
|
|
11
|
+
status: Ref<string>;
|
|
12
|
+
refresh: () => Promise<void>;
|
|
13
|
+
execute: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/** CMS API 请求封装,SSR 直连 CMS,CSR 走 Nuxt 代理。 */
|
|
16
|
+
export declare function useCmsFetch<T>(path: MaybeRefOrGetter<string>, options?: Record<string, unknown> & {
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
}): CmsFetchResult<T>;
|
|
19
|
+
//# sourceMappingURL=useCmsFetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsFetch.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsFetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAIhD,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IACnB,KAAK,EAAE,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IAChC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACnB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,6CAA6C;AAC7C,wBAAgB,WAAW,CAAC,CAAC,EAC3B,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GACvE,cAAc,CAAC,CAAC,CAAC,CAyBnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { useCmsPreviewToken } from "./useCmsPreview.js";
|
|
3
|
+
export function useCmsFetch(path, options) {
|
|
4
|
+
const config = useRuntimeConfig();
|
|
5
|
+
const cmsConfig = config.public.cms;
|
|
6
|
+
const baseURL = import.meta.server ? cmsConfig.apiUrl : cmsConfig.content?.cmsProxyPath ?? "/cms-proxy";
|
|
7
|
+
const headers = { Accept: "application/json" };
|
|
8
|
+
if (cmsConfig.productCode) {
|
|
9
|
+
headers["X-Product-Code"] = cmsConfig.productCode;
|
|
10
|
+
}
|
|
11
|
+
const previewToken = useCmsPreviewToken();
|
|
12
|
+
if (previewToken.value) {
|
|
13
|
+
headers["X-Preview-Token"] = previewToken.value;
|
|
14
|
+
}
|
|
15
|
+
return useFetch(path, {
|
|
16
|
+
...options,
|
|
17
|
+
baseURL,
|
|
18
|
+
headers: { ...headers, ...options?.headers }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 获取预览 token(SWR 安全)。
|
|
4
|
+
*
|
|
5
|
+
* SSR 时从 event.context.__cms_preview_token 读取,该值由 preview-context
|
|
6
|
+
* 中间件写入,通过引用共享穿越 Nitro SWR 合成事件边界。
|
|
7
|
+
* CSR 时从 cookie 读取(客户端不受 SWR 影响)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function useCmsPreviewToken(): Ref<string | null>;
|
|
10
|
+
/** 预览模式管理 */
|
|
11
|
+
export declare function useCmsPreview(): {
|
|
12
|
+
isPreview: import("vue").ComputedRef<boolean>;
|
|
13
|
+
previewToken: Ref<string | null, string | null>;
|
|
14
|
+
exitPreview: () => void;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=useCmsPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsPreview.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsPreview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBvD;AAED,aAAa;AACb,wBAAgB,aAAa;;;;EAkB5B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CmsRouteParams } from '../../types';
|
|
2
|
+
/** CMS 资源路由生成器 */
|
|
3
|
+
export declare function useCmsRoutes(): {
|
|
4
|
+
policy: Required<import("../../types").CmsRoutePolicy>;
|
|
5
|
+
build: (resource: string, params?: CmsRouteParams, includeLocale?: boolean) => string;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=useCmsRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsRoutes.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,kBAAkB;AAClB,wBAAgB,YAAY;;sBAID,MAAM,WAAU,cAAc;EAKxD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { buildCmsPath, resolveCmsRoutePolicy } from "../utils/routes.js";
|
|
3
|
+
export function useCmsRoutes() {
|
|
4
|
+
const config = useRuntimeConfig();
|
|
5
|
+
const policy = resolveCmsRoutePolicy(config.public.cms);
|
|
6
|
+
function build(resource, params = {}, includeLocale = false) {
|
|
7
|
+
return buildCmsPath(policy, resource, params, { includeLocale });
|
|
8
|
+
}
|
|
9
|
+
return { policy, build };
|
|
10
|
+
}
|