@vigilkids/cms-nuxt 0.5.0 → 0.5.2
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 +7 -0
- package/README.md +3 -3
- package/dist/module.d.mts +8 -22
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +14 -0
- package/dist/runtime/composables/useCmsRoutes.d.ts +1 -1
- package/dist/runtime/composables/useCmsRoutes.d.ts.map +1 -1
- package/dist/runtime/composables/useCmsRoutes.js +15 -1
- package/dist/runtime/composables/useCmsSiteConfig.d.ts +3 -0
- package/dist/runtime/composables/useCmsSiteConfig.d.ts.map +1 -0
- package/dist/runtime/composables/useCmsSiteConfig.js +4 -0
- package/dist/runtime/plugins/site-config.d.ts +3 -0
- package/dist/runtime/plugins/site-config.d.ts.map +1 -0
- package/dist/runtime/plugins/site-config.js +14 -0
- package/dist/runtime/server/api/_revalidate.post.d.ts.map +1 -1
- package/dist/runtime/server/api/_revalidate.post.js +3 -3
- package/dist/runtime/server/api/preview.get.d.ts.map +1 -1
- package/dist/runtime/server/api/preview.get.js +15 -7
- package/dist/runtime/server/api/site-config.get.d.ts +3 -0
- package/dist/runtime/server/api/site-config.get.d.ts.map +1 -0
- package/dist/runtime/server/api/site-config.get.js +6 -0
- package/dist/runtime/server/api/sitemap-urls.get.d.ts.map +1 -1
- package/dist/runtime/server/api/sitemap-urls.get.js +2 -5
- package/dist/runtime/server/middleware/redirects.d.ts.map +1 -1
- package/dist/runtime/server/middleware/redirects.js +28 -1
- package/dist/runtime/server/utils/site-config.d.ts +33 -0
- package/dist/runtime/server/utils/site-config.d.ts.map +1 -0
- package/dist/runtime/server/utils/site-config.js +72 -0
- package/dist/runtime/utils/routes.d.ts +2 -18
- package/dist/runtime/utils/routes.d.ts.map +1 -1
- package/dist/runtime/utils/routes.js +8 -119
- package/dist/types.d.ts +11 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ 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.1] - 2026-06-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Ordered CMS redirect middleware rules by priority, match specificity, and source path length.
|
|
13
|
+
- Updated the `@vigilkids/cms-client` peer dependency to `^0.3.1` for redirect priority metadata.
|
|
14
|
+
|
|
8
15
|
## [0.5.0] - 2026-06-03
|
|
9
16
|
|
|
10
17
|
### 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.3.
|
|
16
|
+
- `@vigilkids/cms-client ^0.3.1`
|
|
17
17
|
- `@nuxtjs/sitemap` is optional and only required when `cms.sitemap.enabled` is `true`
|
|
18
18
|
|
|
19
19
|
## Module Setup
|
|
@@ -102,7 +102,7 @@ export default defineNuxtConfig({
|
|
|
102
102
|
| `categories.preload` | `false` | Fetches `/categories` during module setup and exposes the result in public runtime config. |
|
|
103
103
|
| `preview` | enabled by default | Preview route and preview cookie behavior. |
|
|
104
104
|
| `revalidate` | enabled by default | Signed ISR cache invalidation endpoint. |
|
|
105
|
-
| `redirects` | enabled by default | CMS redirect middleware with configurable in-memory cache TTL. |
|
|
105
|
+
| `redirects` | enabled by default | CMS redirect middleware with priority-aware matching and configurable in-memory cache TTL. |
|
|
106
106
|
| `sitemap` | disabled by default | `@nuxtjs/sitemap` provider integration and sitemap source endpoint path. |
|
|
107
107
|
| `localeMap` | `{}` | Maps public locale codes to CMS API locale codes. |
|
|
108
108
|
| `localePrefixes` | `{}` | Additional prefix input merged into `routes.locale.prefixes`. |
|
|
@@ -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.3.
|
|
268
|
+
- `@vigilkids/cms-client ^0.3.1`
|
|
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.d.mts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { RoutePolicy } from '@vigilkids/cms-client/routes';
|
|
2
3
|
|
|
3
|
-
/** CMS 资源路由模式 */
|
|
4
|
-
interface CmsRouteResources {
|
|
5
|
-
index?: string;
|
|
6
|
-
category?: string;
|
|
7
|
-
article?: string;
|
|
8
|
-
author?: string;
|
|
9
|
-
[resource: string]: string | undefined;
|
|
10
|
-
}
|
|
11
|
-
/** CMS 语言路径策略 */
|
|
12
|
-
interface CmsRouteLocalePolicy {
|
|
13
|
-
defaultLocale?: string;
|
|
14
|
-
prefixes?: Record<string, string>;
|
|
15
|
-
includeDefaultLocale?: boolean;
|
|
16
|
-
}
|
|
17
4
|
/** CMS 资源路由策略 */
|
|
18
|
-
|
|
19
|
-
/** 站点公开 URL 模式 */
|
|
20
|
-
resources?: CmsRouteResources;
|
|
21
|
-
/** CMS API 返回的资源 URL 模式,用于 preview/sitemap 输入解析 */
|
|
22
|
-
sourceResources?: CmsRouteResources;
|
|
23
|
-
/** 语言路径策略 */
|
|
24
|
-
locale?: CmsRouteLocalePolicy;
|
|
25
|
-
}
|
|
5
|
+
type CmsRoutePolicy = RoutePolicy;
|
|
26
6
|
/** CMS Nuxt Module 配置 */
|
|
27
7
|
interface CmsNuxtModuleOptions {
|
|
28
8
|
/** CMS API 基础 URL */
|
|
@@ -42,6 +22,12 @@ interface CmsNuxtModuleOptions {
|
|
|
42
22
|
};
|
|
43
23
|
/** CMS 资源路由策略 */
|
|
44
24
|
routes?: CmsRoutePolicy;
|
|
25
|
+
/** 站点运行时配置 */
|
|
26
|
+
site?: {
|
|
27
|
+
url?: string;
|
|
28
|
+
runtime?: boolean;
|
|
29
|
+
cacheTtl?: number;
|
|
30
|
+
};
|
|
45
31
|
/** 内容 API 集成 */
|
|
46
32
|
content?: {
|
|
47
33
|
articleCollectionPath?: string;
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAiEnD,QAAA,MAAM,MAAM,EAAE,UAAU,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,UAAU,EAAE,MAAM,cAAc,CAAA;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAiEnD,QAAA,MAAM,MAAM,EAAE,UAAU,CAAC,oBAAoB,CAkK3C,CAAA;AAEF,eAAe,MAAM,CAAA;AAGrB,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -50,6 +50,7 @@ const module = defineNuxtModule({
|
|
|
50
50
|
defaultLocale: "en",
|
|
51
51
|
webhookSecret: "",
|
|
52
52
|
preview: { cookieName: "__preview_token", cookieMaxAge: 1800 },
|
|
53
|
+
site: { runtime: false, cacheTtl: 3e5 },
|
|
53
54
|
content: { articleCollectionPath: "/api/cms/articles", cmsProxyPath: "/cms-proxy" },
|
|
54
55
|
categories: { preload: false },
|
|
55
56
|
revalidate: { enabled: true, path: "/api/_revalidate" },
|
|
@@ -67,10 +68,12 @@ const module = defineNuxtModule({
|
|
|
67
68
|
const previewPath = options.preview?.path ?? "/api/preview";
|
|
68
69
|
const revalidatePath = options.revalidate?.path ?? "/api/_revalidate";
|
|
69
70
|
const sitemapSourcePath = options.sitemap?.sourcePath ?? "/api/cms/sitemap-urls";
|
|
71
|
+
const siteConfigPath = "/api/cms/site-config";
|
|
70
72
|
applyNoCacheRouteRules(nuxt, [
|
|
71
73
|
articleCollectionPath,
|
|
72
74
|
cmsProxyRoute,
|
|
73
75
|
sitemapSourcePath,
|
|
76
|
+
siteConfigPath,
|
|
74
77
|
previewPath,
|
|
75
78
|
revalidatePath
|
|
76
79
|
]);
|
|
@@ -89,6 +92,11 @@ const module = defineNuxtModule({
|
|
|
89
92
|
cookieName: options.preview?.cookieName ?? "__preview_token",
|
|
90
93
|
cookieMaxAge: options.preview?.cookieMaxAge ?? 1800
|
|
91
94
|
},
|
|
95
|
+
site: {
|
|
96
|
+
url: options.site?.url ?? "",
|
|
97
|
+
runtime: options.site?.runtime ?? false,
|
|
98
|
+
cacheTtl: options.site?.cacheTtl ?? 3e5
|
|
99
|
+
},
|
|
92
100
|
routes: {
|
|
93
101
|
...options.routes ?? {},
|
|
94
102
|
locale: {
|
|
@@ -130,6 +138,11 @@ const module = defineNuxtModule({
|
|
|
130
138
|
method: "get",
|
|
131
139
|
handler: resolve("./runtime/server/api/sitemap-urls.get")
|
|
132
140
|
});
|
|
141
|
+
addServerHandler({
|
|
142
|
+
route: siteConfigPath,
|
|
143
|
+
method: "get",
|
|
144
|
+
handler: resolve("./runtime/server/api/site-config.get")
|
|
145
|
+
});
|
|
133
146
|
addServerHandler({
|
|
134
147
|
route: cmsProxyRoute,
|
|
135
148
|
handler: resolve("./runtime/server/routes/cms-proxy")
|
|
@@ -155,6 +168,7 @@ const module = defineNuxtModule({
|
|
|
155
168
|
src: resolve("./runtime/plugins/preview-init.client"),
|
|
156
169
|
mode: "client"
|
|
157
170
|
});
|
|
171
|
+
addPlugin(resolve("./runtime/plugins/site-config"));
|
|
158
172
|
if (options.sitemap?.enabled) {
|
|
159
173
|
nuxt.hook("sitemap:resolve", async (ctx) => {
|
|
160
174
|
const { sitemapProvider } = await import('../dist/runtime/sitemap/provider.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CmsRouteParams } from '../../types';
|
|
2
2
|
/** CMS 资源路由生成器 */
|
|
3
3
|
export declare function useCmsRoutes(): {
|
|
4
|
-
policy:
|
|
4
|
+
policy: import("@vigilkids/cms-client").ResolvedRoutePolicy;
|
|
5
5
|
build: (resource: string, params?: CmsRouteParams, includeLocale?: boolean) => string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=useCmsRoutes.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAKjD,kBAAkB;AAClB,wBAAgB,YAAY;;sBAmBD,MAAM,WAAU,cAAc;EAKxD"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#imports";
|
|
2
2
|
import { buildCmsPath, resolveCmsRoutePolicy } from "../utils/routes.js";
|
|
3
|
+
import { useCmsSiteConfig } from "./useCmsSiteConfig.js";
|
|
3
4
|
export function useCmsRoutes() {
|
|
4
5
|
const config = useRuntimeConfig();
|
|
5
|
-
const
|
|
6
|
+
const cmsConfig = config.public.cms;
|
|
7
|
+
const siteConfig = useCmsSiteConfig();
|
|
8
|
+
const policy = (() => {
|
|
9
|
+
if (cmsConfig.site?.runtime === false) {
|
|
10
|
+
return resolveCmsRoutePolicy(cmsConfig);
|
|
11
|
+
}
|
|
12
|
+
if (!siteConfig.value) {
|
|
13
|
+
throw new Error("CMS site config is not loaded");
|
|
14
|
+
}
|
|
15
|
+
return resolveCmsRoutePolicy({
|
|
16
|
+
...cmsConfig,
|
|
17
|
+
routes: siteConfig.value.route_policy
|
|
18
|
+
});
|
|
19
|
+
})();
|
|
6
20
|
function build(resource, params = {}, includeLocale = false) {
|
|
7
21
|
return buildCmsPath(policy, resource, params, { includeLocale });
|
|
8
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCmsSiteConfig.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useCmsSiteConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAG7D,wBAAgB,gBAAgB,iEAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-config.d.ts","sourceRoot":"","sources":["../../../src/runtime/plugins/site-config.ts"],"names":[],"mappings":";AAIA,wBAeE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { $fetch, defineNuxtPlugin, useRequestFetch, useRuntimeConfig } from "#imports";
|
|
2
|
+
import { useCmsSiteConfig } from "../composables/useCmsSiteConfig.js";
|
|
3
|
+
export default defineNuxtPlugin(async () => {
|
|
4
|
+
const config = useRuntimeConfig();
|
|
5
|
+
const cmsConfig = config.public.cms;
|
|
6
|
+
if (cmsConfig.site?.runtime === false) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const siteConfig = useCmsSiteConfig();
|
|
10
|
+
if (!siteConfig.value) {
|
|
11
|
+
const requestFetch = import.meta.server ? useRequestFetch() : $fetch;
|
|
12
|
+
siteConfig.value = await requestFetch("/api/cms/site-config");
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_revalidate.post.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/_revalidate.post.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_revalidate.post.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/_revalidate.post.ts"],"names":[],"mappings":"AAkCA,iBAAiB;;;;;;;AACjB,wBAuDE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useRuntimeConfig, useStorage } from "#imports";
|
|
2
2
|
import { verifyWebhookSignature } from "@vigilkids/cms-client/webhook";
|
|
3
3
|
import { createError, defineEventHandler, getHeader, readRawBody } from "h3";
|
|
4
|
-
import { buildCmsPath
|
|
4
|
+
import { buildCmsPath } from "../../utils/routes.js";
|
|
5
|
+
import { resolveServerCmsRoutePolicy } from "../utils/site-config.js";
|
|
5
6
|
function addPath(paths, resource, routePolicy, params) {
|
|
6
7
|
try {
|
|
7
8
|
paths.add(buildCmsPath(routePolicy, resource, params, { includeLocale: true }));
|
|
@@ -32,8 +33,7 @@ export default defineEventHandler(async (event) => {
|
|
|
32
33
|
throw createError({ statusCode: 401, message: "Invalid webhook signature" });
|
|
33
34
|
}
|
|
34
35
|
const payload = JSON.parse(rawBody);
|
|
35
|
-
const cmsConfig =
|
|
36
|
-
const routePolicy = resolveCmsRoutePolicy(cmsConfig);
|
|
36
|
+
const { cmsConfig, routePolicy } = await resolveServerCmsRoutePolicy(event);
|
|
37
37
|
const routeParams = {
|
|
38
38
|
...payload.route_params ?? {},
|
|
39
39
|
locale: publicLocale(payload.locale, cmsConfig.localeMap),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/preview.get.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preview.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/preview.get.ts"],"names":[],"mappings":"AA0BA,+CAA+C;;AAC/C,wBAgEE"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { env } from "node:process";
|
|
2
|
-
import { useRuntimeConfig } from "#imports";
|
|
3
2
|
import { createError, defineEventHandler, getQuery, sendRedirect, setCookie } from "h3";
|
|
4
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
buildCmsPath,
|
|
5
|
+
extractCmsSourceRouteParams,
|
|
6
|
+
mergeCmsRouteParams
|
|
7
|
+
} from "../../utils/routes.js";
|
|
5
8
|
import { createServerCmsClient } from "../utils/cms-client.js";
|
|
9
|
+
import { resolveServerCmsRoutePolicy } from "../utils/site-config.js";
|
|
6
10
|
function stringValue(value) {
|
|
7
11
|
return typeof value === "string" ? value.trim() : "";
|
|
8
12
|
}
|
|
@@ -23,9 +27,7 @@ export default defineEventHandler(async (event) => {
|
|
|
23
27
|
if (!token || resource === "article" && !rawSlug) {
|
|
24
28
|
throw createError({ statusCode: 400, message: "Missing token or slug parameter" });
|
|
25
29
|
}
|
|
26
|
-
const
|
|
27
|
-
const cmsConfig = config.public.cms;
|
|
28
|
-
const routePolicy = resolveCmsRoutePolicy(cmsConfig);
|
|
30
|
+
const { cmsConfig, routePolicy } = await resolveServerCmsRoutePolicy(event);
|
|
29
31
|
const publicLocale = stringValue(query.locale) || routePolicy.locale.defaultLocale || "en";
|
|
30
32
|
const apiLocale = cmsConfig.localeMap?.[publicLocale] ?? publicLocale;
|
|
31
33
|
const cookieName = cmsConfig.preview?.cookieName ?? "__preview_token";
|
|
@@ -38,7 +40,10 @@ export default defineEventHandler(async (event) => {
|
|
|
38
40
|
maxAge: cookieMaxAge
|
|
39
41
|
});
|
|
40
42
|
const sourceParams = rawSlug ? extractCmsSourceRouteParams(routePolicy, resource, rawSlug) : null;
|
|
41
|
-
let routeParams = mergeCmsRouteParams(
|
|
43
|
+
let routeParams = mergeCmsRouteParams(
|
|
44
|
+
queryRouteParams(query),
|
|
45
|
+
sourceParams
|
|
46
|
+
);
|
|
42
47
|
routeParams.locale = publicLocale;
|
|
43
48
|
if (rawSlug && !routeParams.slug) {
|
|
44
49
|
routeParams.slug = rawSlug;
|
|
@@ -46,7 +51,10 @@ export default defineEventHandler(async (event) => {
|
|
|
46
51
|
if (resource === "article" && !routeParams.category_slug && routePolicy.resources.article?.includes("{category_slug}")) {
|
|
47
52
|
const client = createServerCmsClient(token);
|
|
48
53
|
try {
|
|
49
|
-
const article = await client.getArticle(
|
|
54
|
+
const article = await client.getArticle(
|
|
55
|
+
String(routeParams.slug),
|
|
56
|
+
apiLocale
|
|
57
|
+
);
|
|
50
58
|
if (article.category) {
|
|
51
59
|
routeParams = { ...routeParams, category_slug: article.category };
|
|
52
60
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-config.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/site-config.get.ts"],"names":[],"mappings":";AAGA,wBAGE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { defineEventHandler, setResponseHeader } from "h3";
|
|
2
|
+
import { fetchCmsSiteConfig } from "../utils/site-config.js";
|
|
3
|
+
export default defineEventHandler(async (event) => {
|
|
4
|
+
setResponseHeader(event, "Cache-Control", "private, no-cache, no-store");
|
|
5
|
+
return await fetchCmsSiteConfig(event);
|
|
6
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap-urls.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/sitemap-urls.get.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sitemap-urls.get.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/api/sitemap-urls.get.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,wBAcE"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { useRuntimeConfig } from "#imports";
|
|
2
1
|
import { defineEventHandler, getQuery, setResponseHeader } from "h3";
|
|
3
2
|
import { toArray } from "../../utils/list.js";
|
|
4
|
-
import { resolveCmsRoutePolicy } from "../../utils/routes.js";
|
|
5
3
|
import { cmsLocale, toNuxtSitemapEntry } from "../../utils/sitemap.js";
|
|
6
4
|
import { useServerCmsClient } from "../utils/cms-client.js";
|
|
5
|
+
import { resolveServerCmsRoutePolicy } from "../utils/site-config.js";
|
|
7
6
|
export default defineEventHandler(async (event) => {
|
|
8
7
|
setResponseHeader(event, "Cache-Control", "private, no-cache, no-store");
|
|
9
8
|
const { locale } = getQuery(event);
|
|
10
9
|
if (!locale || typeof locale !== "string")
|
|
11
10
|
return [];
|
|
12
|
-
const
|
|
13
|
-
const cmsConfig = config.public.cms;
|
|
14
|
-
const routePolicy = resolveCmsRoutePolicy(cmsConfig);
|
|
11
|
+
const { cmsConfig, routePolicy } = await resolveServerCmsRoutePolicy(event);
|
|
15
12
|
const client = useServerCmsClient();
|
|
16
13
|
const entries = await client.getSitemap(cmsLocale(cmsConfig.localeMap, locale));
|
|
17
14
|
return toArray(entries).map(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/middleware/redirects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redirects.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/middleware/redirects.ts"],"names":[],"mappings":"AAuFA,iBAAiB;;AACjB,wBAiBE"}
|
|
@@ -5,6 +5,31 @@ let cachedRules = null;
|
|
|
5
5
|
let cacheExpiry = 0;
|
|
6
6
|
const regexCache = /* @__PURE__ */ new Map();
|
|
7
7
|
const skippedPrefixes = ["/_", "/__", "/_nuxt", "/_ipx", "/.well-known", "/api"];
|
|
8
|
+
const matchTypeRank = {
|
|
9
|
+
exact: 0,
|
|
10
|
+
prefix: 1,
|
|
11
|
+
regex: 2
|
|
12
|
+
};
|
|
13
|
+
function rulePriority(rule) {
|
|
14
|
+
return Number.isFinite(rule.priority) ? rule.priority : 0;
|
|
15
|
+
}
|
|
16
|
+
function ruleMatchTypeRank(rule) {
|
|
17
|
+
return matchTypeRank[rule.match_type] ?? 3;
|
|
18
|
+
}
|
|
19
|
+
function sortRedirectRules(rules) {
|
|
20
|
+
return [...rules].sort((left, right) => {
|
|
21
|
+
const priorityDiff = rulePriority(right) - rulePriority(left);
|
|
22
|
+
if (priorityDiff !== 0)
|
|
23
|
+
return priorityDiff;
|
|
24
|
+
const matchTypeDiff = ruleMatchTypeRank(left) - ruleMatchTypeRank(right);
|
|
25
|
+
if (matchTypeDiff !== 0)
|
|
26
|
+
return matchTypeDiff;
|
|
27
|
+
const lengthDiff = right.source_path.length - left.source_path.length;
|
|
28
|
+
if (lengthDiff !== 0)
|
|
29
|
+
return lengthDiff;
|
|
30
|
+
return left.source_path.localeCompare(right.source_path);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
8
33
|
async function loadRules() {
|
|
9
34
|
const now = Date.now();
|
|
10
35
|
if (cachedRules && now < cacheExpiry)
|
|
@@ -14,7 +39,9 @@ async function loadRules() {
|
|
|
14
39
|
try {
|
|
15
40
|
const { useServerCmsClient } = await import("../utils/cms-client.js");
|
|
16
41
|
const client = useServerCmsClient();
|
|
17
|
-
cachedRules =
|
|
42
|
+
cachedRules = sortRedirectRules(
|
|
43
|
+
toArray(await client.getRedirects())
|
|
44
|
+
);
|
|
18
45
|
regexCache.clear();
|
|
19
46
|
cacheExpiry = now + cacheTtl;
|
|
20
47
|
return cachedRules;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SiteConfig } from '@vigilkids/cms-client/types';
|
|
2
|
+
import type { H3Event } from 'h3';
|
|
3
|
+
import type { CmsRoutePolicy } from '../../../types';
|
|
4
|
+
interface ServerCmsSiteOptions {
|
|
5
|
+
url?: string;
|
|
6
|
+
runtime?: boolean;
|
|
7
|
+
cacheTtl?: number;
|
|
8
|
+
}
|
|
9
|
+
interface ServerCmsPublicConfig {
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
productCode?: string;
|
|
12
|
+
defaultLocale?: string;
|
|
13
|
+
localeMap?: Record<string, string>;
|
|
14
|
+
localePrefixes?: Record<string, string>;
|
|
15
|
+
routes?: CmsRoutePolicy;
|
|
16
|
+
preview?: {
|
|
17
|
+
cookieName?: string;
|
|
18
|
+
cookieMaxAge?: number;
|
|
19
|
+
};
|
|
20
|
+
site?: ServerCmsSiteOptions;
|
|
21
|
+
}
|
|
22
|
+
export declare function fetchCmsSiteConfig(event: H3Event): Promise<SiteConfig>;
|
|
23
|
+
export declare function resolveServerCmsRoutePolicy(event: H3Event): Promise<{
|
|
24
|
+
cmsConfig: ServerCmsPublicConfig;
|
|
25
|
+
routePolicy: import("@vigilkids/cms-client").ResolvedRoutePolicy;
|
|
26
|
+
siteConfig: null;
|
|
27
|
+
} | {
|
|
28
|
+
cmsConfig: ServerCmsPublicConfig;
|
|
29
|
+
routePolicy: import("@vigilkids/cms-client").ResolvedRoutePolicy;
|
|
30
|
+
siteConfig: SiteConfig;
|
|
31
|
+
}>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=site-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-config.d.ts","sourceRoot":"","sources":["../../../../src/runtime/server/utils/site-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,6BAA6B,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAMpD,UAAU,oBAAoB;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,OAAO,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACxD,IAAI,CAAC,EAAE,oBAAoB,CAAA;CAC5B;AA6CD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAsB5E;AAED,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,OAAO;;;;;;;;GAoB/D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "#imports";
|
|
2
|
+
import { createError, getRequestHeader } from "h3";
|
|
3
|
+
import { resolveCmsRoutePolicy } from "../../utils/routes.js";
|
|
4
|
+
import { useServerCmsClient } from "./cms-client.js";
|
|
5
|
+
const siteConfigCache = /* @__PURE__ */ new Map();
|
|
6
|
+
function normalizeHost(value) {
|
|
7
|
+
return value?.split(",")[0]?.trim().toLowerCase() ?? "";
|
|
8
|
+
}
|
|
9
|
+
function requestHost(event) {
|
|
10
|
+
return normalizeHost(getRequestHeader(event, "x-forwarded-host")) || normalizeHost(getRequestHeader(event, "host"));
|
|
11
|
+
}
|
|
12
|
+
function siteConfigQuery(event, cmsConfig) {
|
|
13
|
+
const siteUrl = cmsConfig.site?.url?.trim();
|
|
14
|
+
if (siteUrl) {
|
|
15
|
+
return { site_url: siteUrl };
|
|
16
|
+
}
|
|
17
|
+
const host = requestHost(event);
|
|
18
|
+
if (!host) {
|
|
19
|
+
throw createError({ statusCode: 400, message: "CMS site host is required" });
|
|
20
|
+
}
|
|
21
|
+
return { host };
|
|
22
|
+
}
|
|
23
|
+
function cacheKey(cmsConfig, query) {
|
|
24
|
+
return JSON.stringify([
|
|
25
|
+
cmsConfig.apiUrl,
|
|
26
|
+
cmsConfig.productCode ?? "",
|
|
27
|
+
query.site_url ?? "",
|
|
28
|
+
query.host ?? ""
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
function publicCmsConfig() {
|
|
32
|
+
const config = useRuntimeConfig();
|
|
33
|
+
return config.public.cms;
|
|
34
|
+
}
|
|
35
|
+
export async function fetchCmsSiteConfig(event) {
|
|
36
|
+
const cmsConfig = publicCmsConfig();
|
|
37
|
+
const query = siteConfigQuery(event, cmsConfig);
|
|
38
|
+
const ttl = cmsConfig.site?.cacheTtl ?? 3e5;
|
|
39
|
+
const key = cacheKey(cmsConfig, query);
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
const cached = siteConfigCache.get(key);
|
|
42
|
+
if (ttl > 0 && cached && cached.expiresAt > now) {
|
|
43
|
+
return cached.value;
|
|
44
|
+
}
|
|
45
|
+
const siteConfig = await useServerCmsClient().getSiteConfig(query);
|
|
46
|
+
if (!siteConfig.route_policy) {
|
|
47
|
+
throw createError({ statusCode: 502, message: "CMS site route_policy is missing" });
|
|
48
|
+
}
|
|
49
|
+
if (ttl > 0) {
|
|
50
|
+
siteConfigCache.set(key, { value: siteConfig, expiresAt: now + ttl });
|
|
51
|
+
}
|
|
52
|
+
return siteConfig;
|
|
53
|
+
}
|
|
54
|
+
export async function resolveServerCmsRoutePolicy(event) {
|
|
55
|
+
const cmsConfig = publicCmsConfig();
|
|
56
|
+
if (cmsConfig.site?.runtime === false) {
|
|
57
|
+
return {
|
|
58
|
+
cmsConfig,
|
|
59
|
+
routePolicy: resolveCmsRoutePolicy(cmsConfig),
|
|
60
|
+
siteConfig: null
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const siteConfig = await fetchCmsSiteConfig(event);
|
|
64
|
+
return {
|
|
65
|
+
cmsConfig,
|
|
66
|
+
routePolicy: resolveCmsRoutePolicy({
|
|
67
|
+
...cmsConfig,
|
|
68
|
+
routes: siteConfig.route_policy
|
|
69
|
+
}),
|
|
70
|
+
siteConfig
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
interface CmsRouteRuntimeConfig {
|
|
4
|
-
defaultLocale?: string;
|
|
5
|
-
localePrefixes?: Record<string, string>;
|
|
6
|
-
routes?: CmsRoutePolicy;
|
|
7
|
-
}
|
|
8
|
-
interface BuildCmsPathOptions {
|
|
9
|
-
includeLocale?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare function resolveCmsRoutePolicy(config?: CmsRouteRuntimeConfig): Required<CmsRoutePolicy>;
|
|
12
|
-
export declare function buildCmsPath(policy: CmsRoutePolicy, resource: string, params?: CmsRouteParams, options?: BuildCmsPathOptions): string;
|
|
13
|
-
export declare function extractCmsRouteParams(pattern: string, path: string): CmsRouteParams | null;
|
|
14
|
-
export declare function extractCmsSourceRouteParams(policy: CmsRoutePolicy, resource: string, path: string): CmsRouteParams | null;
|
|
15
|
-
export declare function mergeCmsRouteParams(left: CmsRouteParams | null | undefined, right: CmsRouteParams | null | undefined): {
|
|
16
|
-
[x: string]: string | number | boolean | null | undefined;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
1
|
+
export { buildRoutePath as buildCmsPath, DEFAULT_ROUTE_RESOURCES as DEFAULT_CMS_ROUTE_RESOURCES, extractRouteParams as extractCmsRouteParams, extractSourceRouteParams as extractCmsSourceRouteParams, mergeRouteParams as mergeCmsRouteParams, resolveRoutePolicy as resolveCmsRoutePolicy, } from '@vigilkids/cms-client/routes';
|
|
2
|
+
export type { BuildRoutePathOptions as BuildCmsPathOptions, RoutePolicyConfig as CmsRouteRuntimeConfig, ResolvedRouteLocalePolicy as ResolvedCmsRouteLocalePolicy, ResolvedRoutePolicy as ResolvedCmsRoutePolicy, } from '@vigilkids/cms-client/routes';
|
|
19
3
|
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/routes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/runtime/utils/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,IAAI,YAAY,EAC9B,uBAAuB,IAAI,2BAA2B,EACtD,kBAAkB,IAAI,qBAAqB,EAC3C,wBAAwB,IAAI,2BAA2B,EACvD,gBAAgB,IAAI,mBAAmB,EACvC,kBAAkB,IAAI,qBAAqB,GAC5C,MAAM,8BAA8B,CAAA;AAErC,YAAY,EACV,qBAAqB,IAAI,mBAAmB,EAC5C,iBAAiB,IAAI,qBAAqB,EAC1C,yBAAyB,IAAI,4BAA4B,EACzD,mBAAmB,IAAI,sBAAsB,GAC9C,MAAM,8BAA8B,CAAA"}
|
|
@@ -1,119 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
function normalizePath(path) {
|
|
11
|
-
const clean = path.split("?")[0]?.split("#")[0] ?? "";
|
|
12
|
-
const withSlash = clean.startsWith("/") ? clean : `/${clean}`;
|
|
13
|
-
const collapsed = withSlash.replace(/\/{2,}/g, "/");
|
|
14
|
-
if (collapsed.length > 1)
|
|
15
|
-
return collapsed.replace(/\/+$/g, "");
|
|
16
|
-
return collapsed;
|
|
17
|
-
}
|
|
18
|
-
function encodePathValue(value) {
|
|
19
|
-
return encodeURIComponent(String(value));
|
|
20
|
-
}
|
|
21
|
-
function localePrefix(locale, policy) {
|
|
22
|
-
if (!locale)
|
|
23
|
-
return "";
|
|
24
|
-
const defaultLocale = policy.defaultLocale ?? "en";
|
|
25
|
-
if (locale === defaultLocale && !policy.includeDefaultLocale)
|
|
26
|
-
return "";
|
|
27
|
-
const prefix = policy.prefixes?.[locale] ?? locale.toLowerCase();
|
|
28
|
-
return `/${trimSlashes(prefix)}`;
|
|
29
|
-
}
|
|
30
|
-
function mergeResources(resources) {
|
|
31
|
-
return {
|
|
32
|
-
...DEFAULT_CMS_ROUTE_RESOURCES,
|
|
33
|
-
...resources ?? {}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function resolveCmsRoutePolicy(config) {
|
|
37
|
-
const routes = config?.routes ?? {};
|
|
38
|
-
const defaultLocale = routes.locale?.defaultLocale ?? config?.defaultLocale ?? "en";
|
|
39
|
-
const prefixes = {
|
|
40
|
-
...config?.localePrefixes ?? {},
|
|
41
|
-
...routes.locale?.prefixes ?? {}
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
resources: mergeResources(routes.resources),
|
|
45
|
-
sourceResources: mergeResources(routes.sourceResources),
|
|
46
|
-
locale: {
|
|
47
|
-
defaultLocale,
|
|
48
|
-
prefixes,
|
|
49
|
-
includeDefaultLocale: routes.locale?.includeDefaultLocale ?? false
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export function buildCmsPath(policy, resource, params = {}, options = {}) {
|
|
54
|
-
const resolvedPolicy = resolveCmsRoutePolicy({ routes: policy });
|
|
55
|
-
const pattern = resolvedPolicy.resources[resource];
|
|
56
|
-
if (!pattern) {
|
|
57
|
-
throw new Error(`CMS route pattern is not configured for resource '${resource}'`);
|
|
58
|
-
}
|
|
59
|
-
const path = normalizePath(pattern.replace(/\{(\w+)\}/g, (_, key) => {
|
|
60
|
-
const value = params[key];
|
|
61
|
-
if (value === void 0 || value === null || value === "") {
|
|
62
|
-
throw new Error(`CMS route parameter '${key}' is required for resource '${resource}'`);
|
|
63
|
-
}
|
|
64
|
-
return encodePathValue(value);
|
|
65
|
-
}));
|
|
66
|
-
if (!options.includeLocale)
|
|
67
|
-
return path;
|
|
68
|
-
return normalizePath(`${localePrefix(String(params.locale ?? ""), resolvedPolicy.locale)}${path}`);
|
|
69
|
-
}
|
|
70
|
-
export function extractCmsRouteParams(pattern, path) {
|
|
71
|
-
const keys = [];
|
|
72
|
-
const source = normalizePath(pattern);
|
|
73
|
-
let expression = "^";
|
|
74
|
-
for (let index = 0; index < source.length; index++) {
|
|
75
|
-
const char = source[index];
|
|
76
|
-
if (char === "{") {
|
|
77
|
-
const closeIndex = source.indexOf("}", index);
|
|
78
|
-
if (closeIndex > index) {
|
|
79
|
-
const key = source.slice(index + 1, closeIndex);
|
|
80
|
-
keys.push(key);
|
|
81
|
-
expression += "([^/]+)";
|
|
82
|
-
index = closeIndex;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
expression += char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
87
|
-
}
|
|
88
|
-
expression += "$";
|
|
89
|
-
const match = normalizePath(path).match(new RegExp(expression));
|
|
90
|
-
if (!match)
|
|
91
|
-
return null;
|
|
92
|
-
const params = {};
|
|
93
|
-
for (let index = 0; index < keys.length; index++) {
|
|
94
|
-
const raw = match[index + 1];
|
|
95
|
-
if (raw)
|
|
96
|
-
params[keys[index]] = decodeURIComponent(raw);
|
|
97
|
-
}
|
|
98
|
-
return params;
|
|
99
|
-
}
|
|
100
|
-
export function extractCmsSourceRouteParams(policy, resource, path) {
|
|
101
|
-
const resolvedPolicy = resolveCmsRoutePolicy({ routes: policy });
|
|
102
|
-
const candidates = [
|
|
103
|
-
resolvedPolicy.sourceResources[resource],
|
|
104
|
-
resolvedPolicy.resources[resource],
|
|
105
|
-
DEFAULT_CMS_ROUTE_RESOURCES[resource]
|
|
106
|
-
].filter((pattern) => Boolean(pattern));
|
|
107
|
-
for (const pattern of candidates) {
|
|
108
|
-
const params = extractCmsRouteParams(pattern, path);
|
|
109
|
-
if (params)
|
|
110
|
-
return params;
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
export function mergeCmsRouteParams(left, right) {
|
|
115
|
-
return {
|
|
116
|
-
...left ?? {},
|
|
117
|
-
...right ?? {}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
buildRoutePath as buildCmsPath,
|
|
3
|
+
DEFAULT_ROUTE_RESOURCES as DEFAULT_CMS_ROUTE_RESOURCES,
|
|
4
|
+
extractRouteParams as extractCmsRouteParams,
|
|
5
|
+
extractSourceRouteParams as extractCmsSourceRouteParams,
|
|
6
|
+
mergeRouteParams as mergeCmsRouteParams,
|
|
7
|
+
resolveRoutePolicy as resolveCmsRoutePolicy
|
|
8
|
+
} from "@vigilkids/cms-client/routes";
|
package/dist/types.d.ts
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
+
import type { RouteLocalePolicy, RouteParams, RoutePolicy, RouteResources } from '@vigilkids/cms-client/routes';
|
|
1
2
|
/** CMS 资源路由参数 */
|
|
2
|
-
export type CmsRouteParams =
|
|
3
|
+
export type CmsRouteParams = RouteParams;
|
|
3
4
|
/** CMS 资源路由模式 */
|
|
4
|
-
export
|
|
5
|
-
index?: string;
|
|
6
|
-
category?: string;
|
|
7
|
-
article?: string;
|
|
8
|
-
author?: string;
|
|
9
|
-
[resource: string]: string | undefined;
|
|
10
|
-
}
|
|
5
|
+
export type CmsRouteResources = RouteResources;
|
|
11
6
|
/** CMS 语言路径策略 */
|
|
12
|
-
export
|
|
13
|
-
defaultLocale?: string;
|
|
14
|
-
prefixes?: Record<string, string>;
|
|
15
|
-
includeDefaultLocale?: boolean;
|
|
16
|
-
}
|
|
7
|
+
export type CmsRouteLocalePolicy = RouteLocalePolicy;
|
|
17
8
|
/** CMS 资源路由策略 */
|
|
18
|
-
export
|
|
19
|
-
/** 站点公开 URL 模式 */
|
|
20
|
-
resources?: CmsRouteResources;
|
|
21
|
-
/** CMS API 返回的资源 URL 模式,用于 preview/sitemap 输入解析 */
|
|
22
|
-
sourceResources?: CmsRouteResources;
|
|
23
|
-
/** 语言路径策略 */
|
|
24
|
-
locale?: CmsRouteLocalePolicy;
|
|
25
|
-
}
|
|
9
|
+
export type CmsRoutePolicy = RoutePolicy;
|
|
26
10
|
/** CMS Nuxt Module 配置 */
|
|
27
11
|
export interface CmsNuxtModuleOptions {
|
|
28
12
|
/** CMS API 基础 URL */
|
|
@@ -42,6 +26,12 @@ export interface CmsNuxtModuleOptions {
|
|
|
42
26
|
};
|
|
43
27
|
/** CMS 资源路由策略 */
|
|
44
28
|
routes?: CmsRoutePolicy;
|
|
29
|
+
/** 站点运行时配置 */
|
|
30
|
+
site?: {
|
|
31
|
+
url?: string;
|
|
32
|
+
runtime?: boolean;
|
|
33
|
+
cacheTtl?: number;
|
|
34
|
+
};
|
|
45
35
|
/** 内容 API 集成 */
|
|
46
36
|
content?: {
|
|
47
37
|
articleCollectionPath?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,cAAc,EACf,MAAM,8BAA8B,CAAA;AAErC,iBAAiB;AACjB,MAAM,MAAM,cAAc,GAAG,WAAW,CAAA;AAExC,iBAAiB;AACjB,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAE9C,iBAAiB;AACjB,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAEpD,iBAAiB;AACjB,MAAM,MAAM,cAAc,GAAG,WAAW,CAAA;AAExC,yBAAyB;AACzB,MAAM,WAAW,oBAAoB;IACnC,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW;IACX,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa;IACb,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,iBAAiB;IACjB,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,cAAc;IACd,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,gBAAgB;IAChB,OAAO,CAAC,EAAE;QACR,qBAAqB,CAAC,EAAE,MAAM,CAAA;QAC9B,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,cAAc;IACd,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KACnB,CAAA;IACD,gBAAgB;IAChB,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,eAAe;IACf,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,iBAAiB;IACjB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vigilkids/cms-nuxt",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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.3.
|
|
47
|
+
"@vigilkids/cms-client": "^0.3.2",
|
|
48
48
|
"nuxt": ">=3.15.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|