@lupinum/ginko-content 0.1.2 → 0.1.3
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/README.md +18 -4
- package/compatibility.json +1 -1
- package/dist/cli.mjs +317 -294
- package/dist/cms-import/index.js +5 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/core/cache-hints.d.ts +9 -1
- package/dist/core/content/collection.js +1 -1
- package/dist/core/content/path.js +1 -1
- package/dist/core/errors.js +5 -1
- package/dist/core/provider-errors +1 -0
- package/dist/core/provider-errors.d.ts +10 -0
- package/dist/core/provider-errors.js +27 -0
- package/dist/core/query/execute.js +12 -3
- package/dist/core/query/filter.js +2 -2
- package/dist/core/query/lower.js +5 -4
- package/dist/features/navigation/build.js +14 -6
- package/dist/features/navigation/canonical.js +1 -1
- package/dist/features/sitemap/query.js +2 -2
- package/dist/integrations/nitro/ingest.d.ts +3 -3
- package/dist/integrations/nitro/ingest.js +3 -3
- package/dist/integrations/nitro/storage.js +3 -1
- package/dist/module.d.mts +151 -526
- package/dist/module.json +1 -1
- package/dist/module.mjs +1091 -722
- package/dist/parsers/csv.js +4 -3
- package/dist/parsers/index.d.ts +2 -5
- package/dist/parsers/index.js +2 -2
- package/dist/parsers/markdown-plugins.d.ts +1 -0
- package/dist/parsers/markdown-plugins.js +83 -1
- package/dist/parsers/markdown.js +1 -1
- package/dist/public/client.d.ts +3 -2
- package/dist/public/client.js +2 -2
- package/dist/public/provider-errors.d.ts +2 -1
- package/dist/public/provider-errors.js +1 -18
- package/dist/public/provider.d.ts +3 -10
- package/dist/public/server.d.ts +6 -1
- package/dist/public/server.js +33 -0
- package/dist/runtime/agent-paths +1 -0
- package/dist/runtime/agent-paths.d.ts +6 -0
- package/dist/runtime/agent-paths.js +41 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer.d.ts +1 -1
- package/dist/runtime/app/composables/head.d.ts +3 -0
- package/dist/runtime/app/composables/head.js +2 -1
- package/dist/runtime/app/composables/hot-reload +1 -0
- package/dist/runtime/app/composables/hot-reload.d.ts +5 -0
- package/dist/runtime/app/composables/hot-reload.js +15 -0
- package/dist/runtime/app/composables/locale-context.d.ts +1 -1
- package/dist/runtime/app/composables/locale-context.js +2 -1
- package/dist/runtime/app/composables/locale.js +2 -2
- package/dist/runtime/app/composables/search.js +10 -6
- package/dist/runtime/app/composables/use-content-document +1 -0
- package/dist/runtime/app/composables/use-content-document.d.ts +29 -0
- package/dist/runtime/app/composables/use-content-document.js +44 -0
- package/dist/runtime/app/composables/use-content-list +1 -0
- package/dist/runtime/app/composables/use-content-list.d.ts +43 -0
- package/dist/runtime/app/composables/use-content-list.js +98 -0
- package/dist/runtime/app/composables/use-content-navigation +1 -0
- package/dist/runtime/app/composables/use-content-navigation.d.ts +40 -0
- package/dist/runtime/app/composables/use-content-navigation.js +102 -0
- package/dist/runtime/app/composables/use-content-page +1 -0
- package/dist/runtime/app/composables/use-content-page.d.ts +47 -0
- package/dist/runtime/app/composables/use-content-page.js +142 -0
- package/dist/runtime/app/composables/use-content-shared +1 -0
- package/dist/runtime/app/composables/use-content-shared.d.ts +13 -0
- package/dist/runtime/app/composables/use-content-shared.js +29 -0
- package/dist/runtime/app/composables/use-content.d.ts +11 -206
- package/dist/runtime/app/composables/use-content.js +4 -377
- package/dist/runtime/app/plugins/hot-reload +1 -0
- package/dist/runtime/app/plugins/hot-reload.js +6 -0
- package/dist/runtime/query/backlinks +1 -0
- package/dist/runtime/query/backlinks.d.ts +8 -0
- package/dist/runtime/query/backlinks.js +90 -0
- package/dist/runtime/query/context +1 -0
- package/dist/runtime/query/context.d.ts +20 -0
- package/dist/runtime/query/context.js +0 -0
- package/dist/runtime/query/documents +1 -0
- package/dist/runtime/query/documents.d.ts +6 -0
- package/dist/runtime/query/documents.js +98 -0
- package/dist/runtime/query/errors +1 -0
- package/dist/runtime/query/errors.d.ts +1 -0
- package/dist/runtime/query/errors.js +4 -0
- package/dist/runtime/query/handles +1 -0
- package/dist/runtime/query/handles.d.ts +2 -0
- package/dist/runtime/query/handles.js +7 -0
- package/dist/runtime/query/locale-options +1 -0
- package/dist/runtime/query/locale-options.d.ts +5 -0
- package/dist/runtime/query/locale-options.js +14 -0
- package/dist/runtime/query/localized-docs +1 -0
- package/dist/runtime/query/localized-docs.d.ts +17 -0
- package/dist/runtime/query/localized-docs.js +44 -0
- package/dist/runtime/query/navigation +1 -0
- package/dist/runtime/query/navigation.d.ts +22 -0
- package/dist/runtime/query/navigation.js +73 -0
- package/dist/runtime/query/pagination +1 -0
- package/dist/runtime/query/pagination.d.ts +7 -0
- package/dist/runtime/query/pagination.js +78 -0
- package/dist/runtime/query/populate +1 -0
- package/dist/runtime/query/populate.d.ts +9 -0
- package/dist/runtime/query/populate.js +106 -0
- package/dist/runtime/query/responses +1 -0
- package/dist/runtime/query/responses.d.ts +10 -0
- package/dist/runtime/query/responses.js +47 -0
- package/dist/runtime/query/unified.d.ts +4 -20
- package/dist/runtime/query/unified.js +14 -544
- package/dist/runtime/query/variants +1 -0
- package/dist/runtime/query/variants.d.ts +11 -0
- package/dist/runtime/query/variants.js +36 -0
- package/dist/runtime/server/agent-http +1 -0
- package/dist/runtime/server/agent-http.d.ts +7 -0
- package/dist/runtime/server/agent-http.js +36 -0
- package/dist/runtime/server/agent-markdown +1 -0
- package/dist/runtime/server/agent-markdown.d.ts +83 -0
- package/dist/runtime/server/agent-markdown.js +449 -0
- package/dist/runtime/server/agent-site +1 -0
- package/dist/runtime/server/agent-site.d.ts +38 -0
- package/dist/runtime/server/agent-site.js +273 -0
- package/dist/runtime/server/api/agent-llms +1 -0
- package/dist/runtime/server/api/agent-llms-full +1 -0
- package/dist/runtime/server/api/agent-llms-full.d.ts +2 -0
- package/dist/runtime/server/api/agent-llms-full.js +13 -0
- package/dist/runtime/server/api/agent-llms.d.ts +2 -0
- package/dist/runtime/server/api/agent-llms.js +14 -0
- package/dist/runtime/server/api/agent-raw +1 -0
- package/dist/runtime/server/api/agent-raw.d.ts +2 -0
- package/dist/runtime/server/api/agent-raw.js +17 -0
- package/dist/runtime/server/api/locales.d.ts +2 -2
- package/dist/runtime/server/api/locales.js +4 -2
- package/dist/runtime/server/api/navigation.d.ts +1 -1
- package/dist/runtime/server/api/query.d.ts +1 -1
- package/dist/runtime/server/api/query.js +4 -1
- package/dist/runtime/server/api/revalidate.js +2 -2
- package/dist/runtime/server/api/site-data.d.ts +1 -1
- package/dist/runtime/server/collection-helpers.js +2 -1
- package/dist/runtime/server/middleware/agent-link-headers +1 -0
- package/dist/runtime/server/middleware/agent-link-headers.d.ts +2 -0
- package/dist/runtime/server/middleware/agent-link-headers.js +42 -0
- package/dist/runtime/server/middleware/agent-markdown +1 -0
- package/dist/runtime/server/middleware/agent-markdown.d.ts +2 -0
- package/dist/runtime/server/middleware/agent-markdown.js +43 -0
- package/dist/runtime/server/plugins/sitemap.js +1 -0
- package/dist/runtime/server/provider-query.d.ts +8 -5
- package/dist/runtime/server/provider-query.js +50 -8
- package/dist/runtime/server/provider-result.d.ts +19 -2
- package/dist/runtime/server/providers/filesystem.js +4 -1
- package/dist/runtime/server/providers/index.d.ts +3 -1
- package/dist/runtime/server/providers/index.js +2 -2
- package/dist/runtime/server/query-api.js +2 -1
- package/dist/runtime/server/query-executor.d.ts +3 -2
- package/dist/runtime/server/query-executor.js +13 -5
- package/dist/runtime/server/search.js +1 -1
- package/dist/runtime/server/sitemap-provider.js +40 -1
- package/dist/runtime/server/sitemap.js +3 -2
- package/dist/runtime/transformers/component-resolver.js +2 -1
- package/dist/runtime/utils/content-components.d.ts +0 -5
- package/dist/storage/content.d.ts +2 -9
- package/dist/storage/references.d.ts +1 -8
- package/dist/storage/references.js +9 -4
- package/dist/testing/provider-contract.js +3 -4
- package/dist/testing/provider-fixture.d.ts +3 -1
- package/dist/testing/provider-fixture.js +27 -14
- package/dist/types/config.d.ts +77 -0
- package/dist/types/config.js +23 -0
- package/dist/types/module.d.ts +15 -5
- package/dist/types/query-parts/collections +1 -0
- package/dist/types/query-parts/collections.d.ts +15 -0
- package/dist/types/query-parts/collections.js +0 -0
- package/dist/types/query-parts/public +1 -0
- package/dist/types/query-parts/public.d.ts +202 -0
- package/dist/types/query-parts/public.js +0 -0
- package/dist/types/query-parts/results +1 -0
- package/dist/types/query-parts/results.d.ts +95 -0
- package/dist/types/query-parts/results.js +0 -0
- package/dist/types/query-parts/transport +1 -0
- package/dist/types/query-parts/transport.d.ts +103 -0
- package/dist/types/query-parts/transport.js +0 -0
- package/dist/types/query.d.ts +4 -870
- package/dist/types/query.js +4 -0
- package/dist/types/runtime.d.ts +2 -2
- package/dist/types/virtual.d.ts +54 -0
- package/dist/types.d.mts +2 -2
- package/dist/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/runtime/app/composables/web-socket +0 -1
- package/dist/runtime/app/composables/web-socket.d.ts +0 -3
- package/dist/runtime/app/composables/web-socket.js +0 -65
- package/dist/runtime/app/plugins/ws +0 -1
- package/dist/runtime/app/plugins/ws.js +0 -7
- /package/dist/runtime/app/plugins/{ws.d.ts → hot-reload.d.ts} +0 -0
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export interface ContentCacheHint {
|
|
2
|
+
tags?: string[];
|
|
3
|
+
paths?: string[];
|
|
4
|
+
maxAge?: number;
|
|
5
|
+
swr?: number;
|
|
6
|
+
etag?: string;
|
|
7
|
+
lastModified?: Date;
|
|
8
|
+
}
|
|
9
|
+
export type ContentCacheHintInput = ContentCacheHint | false;
|
|
2
10
|
export declare const normalizeContentCacheHint: (hint: ContentCacheHint) => ContentCacheHint;
|
|
3
11
|
export declare const mergeContentCacheHints: (current: ContentCacheHint | false | undefined, next: ContentCacheHintInput | undefined) => ContentCacheHint | false | undefined;
|
|
@@ -40,7 +40,7 @@ export const resolveCollections = (file, collections = {}, locales = []) => {
|
|
|
40
40
|
if (isExcluded) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
for (const source of normalizeCollectionSources(collection.source)) {
|
|
43
|
+
for (const source of normalizeCollectionSources(collection.source || [])) {
|
|
44
44
|
const isMatch = createSourceMatcher(source);
|
|
45
45
|
if (isMatch(normalizedFile) || isMatch(localeAgnosticFile)) {
|
|
46
46
|
matches.push(name);
|
|
@@ -100,7 +100,7 @@ const isLocalePrefixedPath = (path, locales) => {
|
|
|
100
100
|
};
|
|
101
101
|
export const prefixPathWithLocale = (path, locale, defaultLocale) => {
|
|
102
102
|
const normalizedPath = normalizeContentPath(path || "/");
|
|
103
|
-
if (!locale || locale === defaultLocale) {
|
|
103
|
+
if (!locale || !defaultLocale || locale === defaultLocale) {
|
|
104
104
|
return normalizedPath;
|
|
105
105
|
}
|
|
106
106
|
return normalizedPath === "/" ? `/${locale}` : `/${locale}${normalizedPath}`;
|
package/dist/core/errors.js
CHANGED
|
@@ -2,7 +2,11 @@ export class ContentError extends Error {
|
|
|
2
2
|
code;
|
|
3
3
|
context;
|
|
4
4
|
constructor(code, message, context = {}, options) {
|
|
5
|
-
super(message
|
|
5
|
+
super(message);
|
|
6
|
+
if (options?.cause !== void 0) {
|
|
7
|
+
;
|
|
8
|
+
this.cause = options.cause;
|
|
9
|
+
}
|
|
6
10
|
this.name = "ContentError";
|
|
7
11
|
this.code = code;
|
|
8
12
|
this.context = context;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './provider-errors.js'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ContentProviderErrorCode = 'unknown_provider' | 'unknown_collection' | 'unsupported_provider_operation' | 'unsupported_query_operator' | 'unsupported_query_shape' | 'data_collection_route_access' | 'data_collection_search_access' | 'data_collection_sitemap_access' | 'missing_locale_route' | 'provider_config_missing' | 'provider_module_missing' | 'provider_module_invalid' | 'provider_result_invalid' | 'unsupported_provider_search_index' | 'unsupported_provider_search' | 'unsupported_provider_site_data' | 'unsupported_provider_prerender';
|
|
2
|
+
export declare const statusForProviderError: Record<ContentProviderErrorCode, number>;
|
|
3
|
+
export interface ContentProviderError extends Error {
|
|
4
|
+
statusCode: number;
|
|
5
|
+
statusMessage: ContentProviderErrorCode;
|
|
6
|
+
data: Record<string, unknown> & {
|
|
7
|
+
code: ContentProviderErrorCode;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const createContentProviderError: (code: ContentProviderErrorCode, message: string, details?: Record<string, unknown>) => ContentProviderError;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const statusForProviderError = {
|
|
2
|
+
unknown_provider: 400,
|
|
3
|
+
unknown_collection: 400,
|
|
4
|
+
unsupported_provider_operation: 400,
|
|
5
|
+
unsupported_query_operator: 400,
|
|
6
|
+
unsupported_query_shape: 400,
|
|
7
|
+
data_collection_route_access: 400,
|
|
8
|
+
data_collection_search_access: 400,
|
|
9
|
+
data_collection_sitemap_access: 400,
|
|
10
|
+
missing_locale_route: 404,
|
|
11
|
+
provider_config_missing: 500,
|
|
12
|
+
provider_module_missing: 500,
|
|
13
|
+
provider_module_invalid: 500,
|
|
14
|
+
provider_result_invalid: 500,
|
|
15
|
+
unsupported_provider_search_index: 400,
|
|
16
|
+
unsupported_provider_search: 400,
|
|
17
|
+
unsupported_provider_site_data: 400,
|
|
18
|
+
unsupported_provider_prerender: 400
|
|
19
|
+
};
|
|
20
|
+
export const createContentProviderError = (code, message, details = {}) => Object.assign(new Error(message), {
|
|
21
|
+
statusCode: statusForProviderError[code],
|
|
22
|
+
statusMessage: code,
|
|
23
|
+
data: {
|
|
24
|
+
code,
|
|
25
|
+
...details
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveGraphCanonicalKey, resolveGraphRouteVariant, resolveGraphVariant, resolveLocaleChain, selectGraphDocuments } from "../content/graph.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ensureArray, get, omit, sortList, withKeys, withoutKeys } from "./operators.js";
|
|
3
3
|
import { normalizeRouteMounts, routeToContentPathCandidates } from "../content/path.js";
|
|
4
4
|
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5
5
|
const includesEntry = (haystack, entry) => typeof haystack === "string" ? haystack.includes(String(entry)) : haystack.includes(entry);
|
|
@@ -91,7 +91,10 @@ const applyQueryPlanSort = (matched, plan) => {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
export const applyQueryPlanProjection = (items, plan) => {
|
|
94
|
-
return
|
|
94
|
+
return items.map((item) => {
|
|
95
|
+
const without = withoutKeys(plan.projection.without)(item);
|
|
96
|
+
return withKeys(plan.projection.only)(without);
|
|
97
|
+
});
|
|
95
98
|
};
|
|
96
99
|
export const finalizeQueryPlanResponse = (matched, plan) => {
|
|
97
100
|
if (plan.mode === "count") {
|
|
@@ -187,6 +190,9 @@ const executeLocalePlan = (graph, plan, options) => {
|
|
|
187
190
|
_fallback: item._locale !== requestedLocale,
|
|
188
191
|
_availableLocales: availableLocales
|
|
189
192
|
};
|
|
193
|
+
if (typeof key !== "string") {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
190
196
|
if (!indexByCanonical.has(key)) {
|
|
191
197
|
indexByCanonical.set(key, merged.length);
|
|
192
198
|
merged.push({ rank, item: enriched });
|
|
@@ -222,7 +228,10 @@ const executeVariantPlan = (graph, plan, options) => {
|
|
|
222
228
|
});
|
|
223
229
|
})() : plan.resolveVariant.route ? (() => {
|
|
224
230
|
const localeChain = plan.resolveVariant.exact ? plan.resolveVariant.locale ? [plan.resolveVariant.locale] : [] : plan.resolveVariant.fallback?.length ? Array.from(new Set([plan.resolveVariant.locale, ...plan.resolveVariant.fallback].filter(Boolean))) : resolveLocaleChain(plan.resolveVariant.locale, defaultLocale, localeFallback || {});
|
|
225
|
-
const candidateLocales = localeChain.length ? localeChain :
|
|
231
|
+
const candidateLocales = localeChain.length ? localeChain : Array.from(new Set(Object.values(graph.byCanonical).flatMap((variants) => Object.keys(variants))));
|
|
232
|
+
if (!candidateLocales.length) {
|
|
233
|
+
candidateLocales.push("");
|
|
234
|
+
}
|
|
226
235
|
const candidates = routeToContentPathCandidates(
|
|
227
236
|
plan.resolveVariant.route,
|
|
228
237
|
plan.resolveVariant.locale,
|
|
@@ -75,8 +75,8 @@ export const compileFallback = (fallback) => {
|
|
|
75
75
|
return Array.isArray(fallback) ? fallback : [fallback];
|
|
76
76
|
};
|
|
77
77
|
export const compileQueryParams = (input) => {
|
|
78
|
-
const path = input.by && "path" in input.by ? normalizeContentPath(input.by.path) : void 0;
|
|
79
|
-
const route = input.by && "route" in input.by ? normalizeContentPath(input.by.route) : void 0;
|
|
78
|
+
const path = input.by && "path" in input.by && typeof input.by.path === "string" ? normalizeContentPath(input.by.path) : void 0;
|
|
79
|
+
const route = input.by && "route" in input.by && typeof input.by.route === "string" ? normalizeContentPath(input.by.route) : void 0;
|
|
80
80
|
const ref = input.by && "ref" in input.by ? input.by.ref : void 0;
|
|
81
81
|
const where = compileWhere(input.where);
|
|
82
82
|
const sort = compileSort(input.sort);
|
package/dist/core/query/lower.js
CHANGED
|
@@ -77,11 +77,12 @@ const lowerWhereCondition = (condition) => {
|
|
|
77
77
|
};
|
|
78
78
|
const lowerSort = (sort = []) => {
|
|
79
79
|
return sort.flatMap((option) => {
|
|
80
|
+
const sortParams = option;
|
|
80
81
|
const meta = {
|
|
81
|
-
locale:
|
|
82
|
-
numeric:
|
|
83
|
-
caseFirst:
|
|
84
|
-
sensitivity:
|
|
82
|
+
locale: sortParams.$locale,
|
|
83
|
+
numeric: sortParams.$numeric,
|
|
84
|
+
caseFirst: sortParams.$caseFirst,
|
|
85
|
+
sensitivity: sortParams.$sensitivity
|
|
85
86
|
};
|
|
86
87
|
return Object.entries(option).filter(([key]) => !key.startsWith("$")).map(([field, direction]) => ({
|
|
87
88
|
field,
|
|
@@ -33,10 +33,13 @@ const sortCanonicalTree = (items) => {
|
|
|
33
33
|
return items;
|
|
34
34
|
};
|
|
35
35
|
export const buildCanonicalNavigation = (contents, configs, fields = []) => {
|
|
36
|
-
const pickNavigationFields = (content) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const pickNavigationFields = (content) => {
|
|
37
|
+
const navigationFields = isObject(content?.navigation) ? content.navigation : {};
|
|
38
|
+
return {
|
|
39
|
+
...pick(["title", ...fields])(content),
|
|
40
|
+
...navigationFields
|
|
41
|
+
};
|
|
42
|
+
};
|
|
40
43
|
const navigation = contents.sort((left, right) => left._path.localeCompare(right._path)).reduce((nav, content) => {
|
|
41
44
|
const parts = content._path.substring(1).split("/");
|
|
42
45
|
const idParts = content._id.split(":").slice(1);
|
|
@@ -56,7 +59,7 @@ export const buildCanonicalNavigation = (contents, configs, fields = []) => {
|
|
|
56
59
|
...content._draft ? { _draft: true } : {}
|
|
57
60
|
};
|
|
58
61
|
if (isIndex) {
|
|
59
|
-
const dirConfig = configs[navItem._path];
|
|
62
|
+
const dirConfig = navItem._path ? configs[navItem._path] : void 0;
|
|
60
63
|
if (typeof dirConfig?.navigation !== "undefined" && !dirConfig.navigation) {
|
|
61
64
|
return nav;
|
|
62
65
|
}
|
|
@@ -92,7 +95,12 @@ export const buildCanonicalNavigation = (contents, configs, fields = []) => {
|
|
|
92
95
|
};
|
|
93
96
|
nodes.push(parent);
|
|
94
97
|
}
|
|
95
|
-
|
|
98
|
+
if (!parent) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const resolvedParent = parent;
|
|
102
|
+
resolvedParent.children ||= [];
|
|
103
|
+
return resolvedParent.children;
|
|
96
104
|
}, nav);
|
|
97
105
|
siblings.push(navItem);
|
|
98
106
|
return nav;
|
|
@@ -14,7 +14,7 @@ const cloneFallbackNode = (node) => ({
|
|
|
14
14
|
export const mergeCanonicalNavigation = (primary = [], fallback = []) => {
|
|
15
15
|
const merged = primary.map((item) => ({
|
|
16
16
|
...item,
|
|
17
|
-
|
|
17
|
+
...item.children ? { children: mergeCanonicalNavigation(item.children, []) } : {}
|
|
18
18
|
}));
|
|
19
19
|
const index = /* @__PURE__ */ new Map();
|
|
20
20
|
for (const item of merged) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContentProviderError } from "../../
|
|
1
|
+
import { createContentProviderError } from "../../core/provider-errors";
|
|
2
2
|
const normalizeSiteUrl = (siteUrl) => siteUrl?.replace(/\/$/, "");
|
|
3
3
|
const resolveSiteUrl = (runtime, explicitSiteUrl) => {
|
|
4
4
|
const normalizedExplicitSiteUrl = normalizeSiteUrl(explicitSiteUrl);
|
|
@@ -13,7 +13,7 @@ const resolveSiteUrl = (runtime, explicitSiteUrl) => {
|
|
|
13
13
|
return runtime.requestSiteUrl;
|
|
14
14
|
}
|
|
15
15
|
if (process.env.NODE_ENV === "production") {
|
|
16
|
-
throw new Error("Content sitemap generation requires site.url or runtimeConfig.public.siteUrl in production.");
|
|
16
|
+
throw new Error("Content sitemap generation requires site.url or runtimeConfig.public.content.siteUrl in production.");
|
|
17
17
|
}
|
|
18
18
|
return "http://localhost";
|
|
19
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StorageValue } from 'unstorage';
|
|
2
2
|
import type { ParsedContent } from '../../types/content';
|
|
3
3
|
import type { ParseContentOptions } from '../../types/runtime';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ResolvedContentContext } from '../../types/module';
|
|
5
5
|
/**
|
|
6
6
|
* Ingest a single source file into an array of `ParsedContent` variants
|
|
7
7
|
* (one per locale, including the default).
|
|
@@ -14,5 +14,5 @@ import type { ContentContext } from '../../types/module';
|
|
|
14
14
|
* schema violations, and collection-path ambiguity all surface as specific
|
|
15
15
|
* `ContentErrorCode`s so HTTP and build-time callers can branch on them.
|
|
16
16
|
*/
|
|
17
|
-
export declare const parseContentVariants: (id: string, content: StorageValue, runtimeContentConfig:
|
|
18
|
-
export declare const parseContent: (id: string, content: StorageValue, runtimeContentConfig:
|
|
17
|
+
export declare const parseContentVariants: (id: string, content: StorageValue, runtimeContentConfig: ResolvedContentContext, opts?: ParseContentOptions) => Promise<ParsedContent[]>;
|
|
18
|
+
export declare const parseContent: (id: string, content: StorageValue, runtimeContentConfig: ResolvedContentContext, opts?: ParseContentOptions) => Promise<ParsedContent>;
|
|
@@ -39,7 +39,7 @@ const parseSource = async (id, body, options) => {
|
|
|
39
39
|
const expandLocaleVariants = async (document, options) => {
|
|
40
40
|
try {
|
|
41
41
|
const collection = document._collection && options.pathMeta?.collections ? options.pathMeta.collections[document._collection] : void 0;
|
|
42
|
-
return expandDataLocaleVariants(document, collection?.i18n);
|
|
42
|
+
return expandDataLocaleVariants(document, collection?.i18n === true ? void 0 : collection?.i18n);
|
|
43
43
|
} catch (cause) {
|
|
44
44
|
throw new ContentError(
|
|
45
45
|
"TRANSFORM_FAILED",
|
|
@@ -86,11 +86,11 @@ export const parseContentVariants = async (id, content, runtimeContentConfig, op
|
|
|
86
86
|
yaml: runtimeContentConfig.yaml,
|
|
87
87
|
transformers: customTransformers,
|
|
88
88
|
pathMeta: {
|
|
89
|
-
defaultLocale: runtimeContentConfig.defaultLocale,
|
|
89
|
+
defaultLocale: runtimeContentConfig.defaultLocale || void 0,
|
|
90
90
|
translatedSlugs: runtimeContentConfig.translatedSlugs,
|
|
91
91
|
locales: runtimeContentConfig.locales,
|
|
92
92
|
respectPathCase: runtimeContentConfig.respectPathCase,
|
|
93
|
-
collections: runtimeContentConfig.collections
|
|
93
|
+
collections: runtimeContentConfig.collections || void 0
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
);
|
|
@@ -42,13 +42,14 @@ const mergeCollectionConfigs = (runtimeCollections = {}, sourceCollections = {})
|
|
|
42
42
|
return Object.fromEntries(Array.from(names).map((name) => {
|
|
43
43
|
const source = sourceCollections[name] || {};
|
|
44
44
|
const runtime = runtimeCollections[name] || {};
|
|
45
|
+
const sourceProviders = source.providers;
|
|
45
46
|
return [
|
|
46
47
|
name,
|
|
47
48
|
{
|
|
48
49
|
...source,
|
|
49
50
|
...runtime,
|
|
50
51
|
...source.schema ? { schema: source.schema } : {},
|
|
51
|
-
...
|
|
52
|
+
...sourceProviders ? { providers: sourceProviders } : {}
|
|
52
53
|
}
|
|
53
54
|
];
|
|
54
55
|
}));
|
|
@@ -58,6 +59,7 @@ export const contentConfig = () => {
|
|
|
58
59
|
const sourceContent = virtualContentConfig || {};
|
|
59
60
|
return {
|
|
60
61
|
...runtimeContent,
|
|
62
|
+
...sourceContent.agent ? { agent: sourceContent.agent } : {},
|
|
61
63
|
collections: mergeCollectionConfigs(runtimeContent.collections, sourceContent.collections)
|
|
62
64
|
};
|
|
63
65
|
};
|