@lupinum/ginko-content 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "Ginko Content release compatibility",
3
3
  "releaseStack": {
4
- "@lupinum/ginko-content": "0.1.5",
4
+ "@lupinum/ginko-content": "0.1.6",
5
5
  "@lupinum/ginko-cms": "0.1.2",
6
6
  "@lupinum/ginko-cms-convex": "0.1.1",
7
7
  "@lupinum/ginko-cms-contract": "0.1.1"
@@ -1,6 +1,5 @@
1
1
  import { prefixStorage } from "unstorage";
2
2
  import { useStorage } from "nitropack/runtime";
3
- import virtualContentConfig from "#content/virtual/config";
4
3
  import { makeIgnored } from "../../core/content/ignore";
5
4
  import { getContentRuntimeContext } from "./context.js";
6
5
  import { getPreview, isPreview } from "./preview.js";
@@ -34,34 +33,8 @@ export const cacheParsedStorage = (event) => {
34
33
  }
35
34
  return createScopedStorage("cache:content:parsed");
36
35
  };
37
- const mergeCollectionConfigs = (runtimeCollections = {}, sourceCollections = {}) => {
38
- const names = /* @__PURE__ */ new Set([
39
- ...Object.keys(sourceCollections),
40
- ...Object.keys(runtimeCollections)
41
- ]);
42
- return Object.fromEntries(Array.from(names).map((name) => {
43
- const source = sourceCollections[name] || {};
44
- const runtime = runtimeCollections[name] || {};
45
- const sourceProviders = source.providers;
46
- return [
47
- name,
48
- {
49
- ...source,
50
- ...runtime,
51
- ...source.schema ? { schema: source.schema } : {},
52
- ...sourceProviders ? { providers: sourceProviders } : {}
53
- }
54
- ];
55
- }));
56
- };
57
36
  export const contentConfig = () => {
58
- const runtimeContent = getContentRuntimeConfig().content;
59
- const sourceContent = virtualContentConfig || {};
60
- return {
61
- ...runtimeContent,
62
- ...sourceContent.agent ? { agent: sourceContent.agent } : {},
63
- collections: mergeCollectionConfigs(runtimeContent.collections, sourceContent.collections)
64
- };
37
+ return getContentRuntimeConfig().content;
65
38
  };
66
39
  export const contentIgnorePredicate = (key) => {
67
40
  const isIgnored = makeIgnored(contentConfig().ignores);
package/dist/module.d.mts CHANGED
@@ -132,6 +132,15 @@ interface ContentAgentConfig {
132
132
  sections?: ContentAgentSectionConfig[];
133
133
  pages?: ContentAgentAppPageConfig[];
134
134
  }
135
+ interface ContentAgentRuntimeAppPageConfig extends Omit<ContentAgentAppPageConfig, 'title' | 'description' | 'render'> {
136
+ title: ContentAgentLocalizedValue;
137
+ description: ContentAgentLocalizedValue;
138
+ markdown: ContentAgentLocalizedValue;
139
+ render?: ContentAgentAppPageConfig['render'];
140
+ }
141
+ interface ContentAgentRuntimeConfig extends Omit<ContentAgentConfig, 'pages'> {
142
+ pages?: ContentAgentRuntimeAppPageConfig[];
143
+ }
135
144
  /**
136
145
  * Object source shape accepted for Nuxt Content v3 migration.
137
146
  */
@@ -1751,4 +1760,4 @@ interface ModuleHooks {
1751
1760
  }
1752
1761
 
1753
1762
  export { _default as default, normalizeContentConfigCollectionNames };
1754
- export type { AgentMetadataField, AgentMetadataFieldList, BacklinkFields, BacklinkSource, BacklinksOptions, BacklinksResult, CollectionQueryBuilder, CollectionQueryField, CollectionQueryFieldValue, CollectionQueryKey, CollectionQueryOperator, CollectionQueryValue, CollectionSchema, ContentAgentAppPageConfig, ContentAgentAppPageContext, ContentAgentCollectionConfig, ContentAgentConfig, ContentAgentLocalizedValue, ContentAgentMarkdownMetadataConfig, ContentAgentMarkdownOptions, ContentAgentMarkdownPolicyConfig, ContentAgentRouteOptions, ContentAgentSectionConfig, ContentAgentSiteConfig, ContentCacheArtifact, ContentCmsCollectionConfig, ContentCmsFieldConfig, ContentCmsFieldType, ContentCmsRelationConfig, ContentCollectionConfig, ContentCollectionHandle, ContentCollectionI18nConfig, ContentCollectionI18nMap, ContentCollectionItem, ContentCollectionItemSurroundingsOptions, ContentCollectionKind, ContentCollectionMap, ContentCollectionName, ContentCollectionNavigationOptions, ContentCollectionPageOptions, ContentCollectionRouteConfig, ContentCollectionRouteMetaOptions, ContentCollectionSearchSectionsOptions, ContentCollectionSource, ContentCollectionSourceObject, ContentCollectionStringName, ContentCollectionTarget, ContentConfig, ContentContext, ContentI18nOptions, ContentLinkRouteTarget, ContentLinksOptions, ContentLocaleEntry, ContentLocaleRoute, ContentManifest, ContentMiniSearchOptions, ContentNavigationItem, ContentPageResult, ContentPreviewOptions, ContentProviderName, ContentProviderSearchRequest, ContentQueryBuilder, ContentQueryBuilderParams, ContentQueryBuilderWhere, ContentQueryFetcher, ContentQueryRequest, ContentQuerySortFields, ContentQuerySortOptions, ContentQuerySortParams, ContentReferenceSchema, ContentResolvedMeta, ContentRevalidateOptions, ContentRouteMeta, ContentSearchEngine, ContentSearchIndexRecord, ContentSearchOptions, ContentSearchPublicRuntimeConfig, ContentSearchResult, ContentSearchSection, ContentSelector, ContentSeoImage, ContentSeoMeta, ContentSitemapAlternative, ContentSitemapAssertOptions, ContentSitemapAssertSitemapOptions, ContentSitemapEntry, ContentSitemapImage, ContentSitemapOptions, ContentTransformer, ContentTreeItem, ContentVariant, DefineCollectionObject, DefineCollectionOptions, DocumentFromHandle, LocaleFallback, LocalePathEntry, LocalizedContentDocument, LocalizedDoc, ManifestVariant, ManyOptions, MarkdownNode, MarkdownOptions, MarkdownParsedContent, MarkdownPluginDescriptor, MarkdownPluginOptions, MarkdownRoot, ModuleHooks, ModuleOptions, MountOptions, NavItem, NeighborsOptions, NeighborsResult, OneOptions, PaginationOptions, PaginationResult, ParseContentOptions, ParsedContent, ParsedContentInternalMeta, ParsedContentMeta, PopulateFromOptions, PopulateSpec, PopulatedDocument, QueryGroupBuilder, QueryGroupFunction, QueryMatchOperator, QueryOperators, QueryOrderDirection, QueryOrderOptions, QueryWhere, ResolutionEnvelope, ResolveContentReferenceOptions, ResolveOneOptions, ResolveOneResult, ResolvedContentContext, ResolvedContentI18nOptions, ResolvedMarkdownPlugin, ResolvedVariant, SortDirection, SortSpec, StrictParsedContent, StrictParsedContentMeta, Toc, TocLink, TransformContentOptions, TransformContentSource, TreeOptions, VariantsOptions };
1763
+ export type { AgentMetadataField, AgentMetadataFieldList, BacklinkFields, BacklinkSource, BacklinksOptions, BacklinksResult, CollectionQueryBuilder, CollectionQueryField, CollectionQueryFieldValue, CollectionQueryKey, CollectionQueryOperator, CollectionQueryValue, CollectionSchema, ContentAgentAppPageConfig, ContentAgentAppPageContext, ContentAgentCollectionConfig, ContentAgentConfig, ContentAgentLocalizedValue, ContentAgentMarkdownMetadataConfig, ContentAgentMarkdownOptions, ContentAgentMarkdownPolicyConfig, ContentAgentRouteOptions, ContentAgentRuntimeAppPageConfig, ContentAgentRuntimeConfig, ContentAgentSectionConfig, ContentAgentSiteConfig, ContentCacheArtifact, ContentCmsCollectionConfig, ContentCmsFieldConfig, ContentCmsFieldType, ContentCmsRelationConfig, ContentCollectionConfig, ContentCollectionHandle, ContentCollectionI18nConfig, ContentCollectionI18nMap, ContentCollectionItem, ContentCollectionItemSurroundingsOptions, ContentCollectionKind, ContentCollectionMap, ContentCollectionName, ContentCollectionNavigationOptions, ContentCollectionPageOptions, ContentCollectionRouteConfig, ContentCollectionRouteMetaOptions, ContentCollectionSearchSectionsOptions, ContentCollectionSource, ContentCollectionSourceObject, ContentCollectionStringName, ContentCollectionTarget, ContentConfig, ContentContext, ContentI18nOptions, ContentLinkRouteTarget, ContentLinksOptions, ContentLocaleEntry, ContentLocaleRoute, ContentManifest, ContentMiniSearchOptions, ContentNavigationItem, ContentPageResult, ContentPreviewOptions, ContentProviderName, ContentProviderSearchRequest, ContentQueryBuilder, ContentQueryBuilderParams, ContentQueryBuilderWhere, ContentQueryFetcher, ContentQueryRequest, ContentQuerySortFields, ContentQuerySortOptions, ContentQuerySortParams, ContentReferenceSchema, ContentResolvedMeta, ContentRevalidateOptions, ContentRouteMeta, ContentSearchEngine, ContentSearchIndexRecord, ContentSearchOptions, ContentSearchPublicRuntimeConfig, ContentSearchResult, ContentSearchSection, ContentSelector, ContentSeoImage, ContentSeoMeta, ContentSitemapAlternative, ContentSitemapAssertOptions, ContentSitemapAssertSitemapOptions, ContentSitemapEntry, ContentSitemapImage, ContentSitemapOptions, ContentTransformer, ContentTreeItem, ContentVariant, DefineCollectionObject, DefineCollectionOptions, DocumentFromHandle, LocaleFallback, LocalePathEntry, LocalizedContentDocument, LocalizedDoc, ManifestVariant, ManyOptions, MarkdownNode, MarkdownOptions, MarkdownParsedContent, MarkdownPluginDescriptor, MarkdownPluginOptions, MarkdownRoot, ModuleHooks, ModuleOptions, MountOptions, NavItem, NeighborsOptions, NeighborsResult, OneOptions, PaginationOptions, PaginationResult, ParseContentOptions, ParsedContent, ParsedContentInternalMeta, ParsedContentMeta, PopulateFromOptions, PopulateSpec, PopulatedDocument, QueryGroupBuilder, QueryGroupFunction, QueryMatchOperator, QueryOperators, QueryOrderDirection, QueryOrderOptions, QueryWhere, ResolutionEnvelope, ResolveContentReferenceOptions, ResolveOneOptions, ResolveOneResult, ResolvedContentContext, ResolvedContentI18nOptions, ResolvedMarkdownPlugin, ResolvedVariant, SortDirection, SortSpec, StrictParsedContent, StrictParsedContentMeta, Toc, TocLink, TransformContentOptions, TransformContentSource, TreeOptions, VariantsOptions };
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lupinum/ginko-content",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "configKey": "content",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
package/dist/module.mjs CHANGED
@@ -30,7 +30,7 @@ export { agentMetadataFields, defineAgentAppPage, defineAgentMarkdownPolicy, def
30
30
  import { collectTopLevelReferenceFieldsByTarget } from '../dist/core/references/schema';
31
31
 
32
32
  const name = "@lupinum/ginko-content";
33
- const version = "0.1.5";
33
+ const version = "0.1.6";
34
34
 
35
35
  const CONFIG_FILES = [
36
36
  "content.config.ts",
@@ -52,7 +52,7 @@ async function loadContentConfig(nuxt) {
52
52
  return loaded?.default || loaded || {};
53
53
  }
54
54
 
55
- const createVirtualContentTemplates = (contentContext, nuxt, contentConfigPath, addTemplateImpl) => {
55
+ const createVirtualContentTemplates = (contentContext, nuxt, _contentConfigPath, addTemplateImpl) => {
56
56
  const transformersTemplate = addTemplateImpl({
57
57
  filename: "content/virtual-transformers.mjs",
58
58
  write: true,
@@ -73,10 +73,7 @@ const createVirtualContentTemplates = (contentContext, nuxt, contentConfigPath,
73
73
  const virtualConfigTemplate = addTemplateImpl({
74
74
  filename: "content/virtual-config.mjs",
75
75
  write: true,
76
- getContents: () => contentConfigPath ? [
77
- `import config from ${JSON.stringify(contentConfigPath)}`,
78
- "export default config || {}"
79
- ].join("\n") : "export default {}"
76
+ getContents: () => "export default {}"
80
77
  }).dst;
81
78
  const virtualProvidersTemplate = addTemplateImpl({
82
79
  filename: "content/virtual-providers.mjs",
@@ -1499,15 +1496,6 @@ const registerContentNitroConfig = ({
1499
1496
  nitroConfig.prerender.routes.push(`/${locale}/llms.txt`, `/${locale}/llms-full.txt`);
1500
1497
  }
1501
1498
  }
1502
- for (const page of appContentConfig.agent.pages || []) {
1503
- const routes = typeof page.route === "string" ? [page.route] : Object.values(page.route);
1504
- for (const route of routes) {
1505
- const normalized = route === "/" ? "/" : `/${route.replace(/^\/+|\/+$/g, "")}`;
1506
- nitroConfig.prerender.routes.push(
1507
- normalized === "/" ? "/raw/index.md" : `/raw${normalized}.md`
1508
- );
1509
- }
1510
- }
1511
1499
  }
1512
1500
  });
1513
1501
  };
@@ -1664,7 +1652,55 @@ const sanitizePrivateMarkdownPlugins = (plugins) => plugins.map((plugin) => ({
1664
1652
  name: plugin.name,
1665
1653
  options: sanitizePrivateMarkdownPluginValue(plugin.options || {})
1666
1654
  }));
1667
- const applyContentRuntimeConfig = (nuxt, options, contentContext, runtimeCollections, buildIntegrity, cacheIntegrity) => {
1655
+ const localizedValue = (value, locale, fallback = "") => {
1656
+ if (typeof value === "string") return value;
1657
+ if (!value) return fallback;
1658
+ return value[locale] || Object.values(value)[0] || fallback;
1659
+ };
1660
+ const resolveAgentAppPageValue = async (value, ctx) => {
1661
+ if (typeof value === "function") {
1662
+ return await value(ctx);
1663
+ }
1664
+ return localizedValue(value, ctx.locale);
1665
+ };
1666
+ const sanitizeAgentConfig = async (agent, contentContext, siteUrl) => {
1667
+ if (!agent) {
1668
+ return void 0;
1669
+ }
1670
+ const defaultLocale = agent.site?.defaultLocale || contentContext.defaultLocale || contentContext.locales?.[0] || "en";
1671
+ const locales = agent.site?.locales?.length ? agent.site.locales : contentContext.locales?.length ? contentContext.locales : [defaultLocale];
1672
+ const agentSiteUrl = siteUrl || agent.site?.url || "http://localhost:3000";
1673
+ const pages = await Promise.all((agent.pages || []).map(async (page) => {
1674
+ const title = {};
1675
+ const description = {};
1676
+ const markdown = {};
1677
+ for (const locale of locales) {
1678
+ const ctx = { locale, defaultLocale, siteUrl: agentSiteUrl };
1679
+ title[locale] = await resolveAgentAppPageValue(page.title, ctx);
1680
+ description[locale] = await resolveAgentAppPageValue(page.description, ctx);
1681
+ markdown[locale] = await page.render(ctx);
1682
+ }
1683
+ return {
1684
+ id: page.id,
1685
+ route: page.route,
1686
+ section: page.section,
1687
+ title,
1688
+ description,
1689
+ updated: page.updated,
1690
+ includeInIndex: page.includeInIndex,
1691
+ includeInFull: page.includeInFull,
1692
+ metadata: page.metadata,
1693
+ markdown
1694
+ };
1695
+ }));
1696
+ return {
1697
+ ...agent.site ? { site: agent.site } : {},
1698
+ ...agent.markdown ? { markdown: agent.markdown } : {},
1699
+ ...agent.sections ? { sections: agent.sections } : {},
1700
+ ...pages.length ? { pages } : {}
1701
+ };
1702
+ };
1703
+ const applyContentRuntimeConfig = async (nuxt, options, contentContext, appContentConfig, runtimeCollections, privateRuntimeCollections, buildIntegrity, cacheIntegrity) => {
1668
1704
  const revalidate = options.revalidate === false ? void 0 : options.revalidate;
1669
1705
  const searchRuntime = contentContext.search === false ? false : {
1670
1706
  apiBaseURL: contentContext.search.apiBaseURL || `${options.api.baseURL.replace(/\/$/, "")}/search`,
@@ -1708,8 +1744,10 @@ const applyContentRuntimeConfig = (nuxt, options, contentContext, runtimeCollect
1708
1744
  navigation: contentContext.navigation,
1709
1745
  contentHead: options.contentHead ?? true
1710
1746
  });
1747
+ const runtimeAgent = await sanitizeAgentConfig(appContentConfig.agent, contentContext, siteUrl);
1711
1748
  const privateContentRuntime = {
1712
1749
  ...contentContext,
1750
+ ...runtimeAgent ? { agent: runtimeAgent } : {},
1713
1751
  markdown: {
1714
1752
  ...contentContext.markdown,
1715
1753
  plugins: sanitizePrivateMarkdownPlugins(contentContext.markdown.plugins)
@@ -1724,13 +1762,14 @@ const applyContentRuntimeConfig = (nuxt, options, contentContext, runtimeCollect
1724
1762
  allowUnsigned: revalidate.allowUnsigned === true
1725
1763
  } : false,
1726
1764
  ...privateContentRuntime,
1727
- collections: runtimeCollections
1765
+ collections: privateRuntimeCollections
1728
1766
  });
1729
1767
  };
1730
1768
 
1731
1769
  const registerContentContextFinalization = ({
1732
1770
  nuxt,
1733
1771
  options,
1772
+ appContentConfig,
1734
1773
  contentContext,
1735
1774
  buildIntegrity,
1736
1775
  resolvePath,
@@ -1751,22 +1790,31 @@ const registerContentContextFinalization = ({
1751
1790
  };
1752
1791
  onResolved(resolvedContentContext);
1753
1792
  await validateBuiltinMarkdownPlugins(resolvedContentContext.markdown.plugins, resolvePath);
1754
- const runtimeCollections = Object.fromEntries(Object.entries(options.collections || {}).map(([name, collection]) => {
1793
+ const collectionEntries = Object.entries(options.collections || {}).map(([name, collection]) => {
1755
1794
  const references = collectTopLevelReferenceFieldsByTarget(collection.schema);
1756
- return [
1757
- name,
1758
- {
1759
- ...collection.source ? { source: collection.source } : {},
1760
- ...collection.exclude ? { exclude: collection.exclude } : {},
1761
- ...collection.type ? { type: collection.type } : {},
1762
- strict: collection.strict ?? true,
1763
- ...collection.route ? { route: collection.route } : {},
1764
- ...typeof collection.sitemap === "boolean" ? { sitemap: collection.sitemap } : {},
1765
- ...collection.i18n && collection.i18n !== true ? { i18n: collection.i18n } : {},
1766
- ...Object.keys(references).length ? { references } : {}
1767
- }
1768
- ];
1769
- }));
1795
+ const runtimeCollection = {
1796
+ ...collection.source ? { source: collection.source } : {},
1797
+ ...collection.exclude ? { exclude: collection.exclude } : {},
1798
+ ...collection.type ? { type: collection.type } : {},
1799
+ strict: collection.strict ?? true,
1800
+ ...collection.route ? { route: collection.route } : {},
1801
+ ...typeof collection.translatedSlugs === "boolean" ? { translatedSlugs: collection.translatedSlugs } : {},
1802
+ ...typeof collection.sitemap === "boolean" ? { sitemap: collection.sitemap } : {},
1803
+ ...collection.i18n && collection.i18n !== true ? { i18n: collection.i18n } : {},
1804
+ ...collection.cms ? { cms: collection.cms } : {},
1805
+ ...collection.agent ? { agent: collection.agent } : {},
1806
+ ...Object.keys(references).length ? { references } : {}
1807
+ };
1808
+ return [name, runtimeCollection, collection];
1809
+ });
1810
+ const runtimeCollections = Object.fromEntries(collectionEntries.map(([name, runtimeCollection]) => [name, runtimeCollection]));
1811
+ const privateRuntimeCollections = Object.fromEntries(collectionEntries.map(([name, runtimeCollection, collection]) => [
1812
+ name,
1813
+ {
1814
+ ...runtimeCollection,
1815
+ ...nuxt.options.dev && collection.schema ? { schema: collection.schema } : {}
1816
+ }
1817
+ ]));
1770
1818
  const cacheIntegrity = hash({
1771
1819
  locales: resolvedContentContext.locales,
1772
1820
  defaultLocale: resolvedContentContext.defaultLocale,
@@ -1779,7 +1827,7 @@ const registerContentContextFinalization = ({
1779
1827
  yaml: resolvedContentContext.yaml,
1780
1828
  csv: resolvedContentContext.csv
1781
1829
  });
1782
- applyContentRuntimeConfig(nuxt, options, resolvedContentContext, runtimeCollections, buildIntegrity, cacheIntegrity);
1830
+ await applyContentRuntimeConfig(nuxt, options, resolvedContentContext, appContentConfig, runtimeCollections, privateRuntimeCollections, buildIntegrity, cacheIntegrity);
1783
1831
  });
1784
1832
  };
1785
1833
 
@@ -1939,6 +1987,7 @@ const module$1 = defineNuxtModule({
1939
1987
  registerContentContextFinalization({
1940
1988
  nuxt,
1941
1989
  options,
1990
+ appContentConfig,
1942
1991
  contentContext,
1943
1992
  buildIntegrity,
1944
1993
  resolvePath,
@@ -49,6 +49,12 @@ const resolveLocalizedMaybeFunction = async (value, ctx) => {
49
49
  if (typeof value === "function") return await value(ctx);
50
50
  return localizedValue(value, ctx.locale);
51
51
  };
52
+ const resolveAppPageMarkdown = async (page, ctx) => {
53
+ if (typeof page.render === "function") {
54
+ return await page.render(ctx);
55
+ }
56
+ return localizedValue(page.markdown, ctx.locale);
57
+ };
52
58
  const resolveAppPageRoute = (page, locale) => normalizeAgentRoutePath(localizedValue(page.route, locale, "/"));
53
59
  const createAppPageContext = (locale, siteUrl) => ({
54
60
  locale,
@@ -96,6 +102,7 @@ const createAppOwnedAgentPages = async (locale, siteUrl) => {
96
102
  const path = resolveAppPageRoute(page, locale);
97
103
  const rawPath = agentRawPathForRoute(path);
98
104
  const section = resolveSection(page.section, locale);
105
+ const markdown = await resolveAppPageMarkdown(page, ctx);
99
106
  result.push({
100
107
  title: await resolveLocalizedMaybeFunction(page.title, ctx),
101
108
  description: await resolveLocalizedMaybeFunction(page.description, ctx),
@@ -113,7 +120,7 @@ const createAppOwnedAgentPages = async (locale, siteUrl) => {
113
120
  metadataFields: page.metadata,
114
121
  includeInIndex: page.includeInIndex !== false,
115
122
  includeInFull: page.includeInFull !== false,
116
- markdown: await page.render(ctx)
123
+ markdown
117
124
  });
118
125
  }
119
126
  return result;
@@ -47,6 +47,29 @@ const collectReferenceIssues = (schema, value, resolveReference, issues, path =
47
47
  }
48
48
  }
49
49
  };
50
+ const collectDerivedReferenceIssues = (references, value, resolveReference, issues) => {
51
+ if (!references) {
52
+ return;
53
+ }
54
+ for (const [collection, fields] of Object.entries(references)) {
55
+ for (const field of fields) {
56
+ const fieldValue = value[field];
57
+ const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
58
+ for (const item of values) {
59
+ if (typeof item === "undefined" || item === null) {
60
+ continue;
61
+ }
62
+ if (typeof item !== "string") {
63
+ issues.push(`${field}: expected a string reference`);
64
+ continue;
65
+ }
66
+ if (!resolveReference(item, collection === "*" ? void 0 : collection)) {
67
+ issues.push(`${field}: unresolved reference "${item}"${collection !== "*" ? ` in collection "${collection}"` : ""}`);
68
+ }
69
+ }
70
+ }
71
+ }
72
+ };
50
73
  const internalDocumentFields = /* @__PURE__ */ new Set([
51
74
  "_id",
52
75
  "_file",
@@ -310,18 +333,24 @@ export const validateContentGraph = (contents, config) => {
310
333
  continue;
311
334
  }
312
335
  const collection = getCollectionConfig(document._collection, config.collections);
336
+ const references = collection?.references;
313
337
  const schema = collection?.schema;
314
- if (!schema) {
338
+ if (!schema && !references) {
315
339
  continue;
316
340
  }
317
341
  const issues = [];
318
- collectReferenceIssues(schema, document, (value, collection2) => {
342
+ const resolveReference = (value, collection2) => {
319
343
  const canonicalId = referenceTargets.get(normalizeReferenceValue(value));
320
344
  if (!canonicalId) {
321
345
  return false;
322
346
  }
323
347
  return collection2 ? targetCollections.get(canonicalId)?.has(collection2) === true : true;
324
- }, issues);
348
+ };
349
+ if (schema) {
350
+ collectReferenceIssues(schema, document, resolveReference, issues);
351
+ } else {
352
+ collectDerivedReferenceIssues(references, document, resolveReference, issues);
353
+ }
325
354
  if (!issues.length) {
326
355
  continue;
327
356
  }
@@ -125,6 +125,15 @@ export interface ContentAgentConfig {
125
125
  sections?: ContentAgentSectionConfig[];
126
126
  pages?: ContentAgentAppPageConfig[];
127
127
  }
128
+ export interface ContentAgentRuntimeAppPageConfig extends Omit<ContentAgentAppPageConfig, 'title' | 'description' | 'render'> {
129
+ title: ContentAgentLocalizedValue;
130
+ description: ContentAgentLocalizedValue;
131
+ markdown: ContentAgentLocalizedValue;
132
+ render?: ContentAgentAppPageConfig['render'];
133
+ }
134
+ export interface ContentAgentRuntimeConfig extends Omit<ContentAgentConfig, 'pages'> {
135
+ pages?: ContentAgentRuntimeAppPageConfig[];
136
+ }
128
137
  /**
129
138
  * Object source shape accepted for Nuxt Content v3 migration.
130
139
  */
package/dist/types.d.mts CHANGED
@@ -8,4 +8,4 @@ export { type agentMetadataFields, type defineAgentAppPage, type defineAgentMark
8
8
 
9
9
  export { default, type normalizeContentConfigCollectionNames } from './module.mjs'
10
10
 
11
- export { type AgentMetadataField, type AgentMetadataFieldList, type BacklinkFields, type BacklinkSource, type BacklinksOptions, type BacklinksResult, type CollectionQueryBuilder, type CollectionQueryField, type CollectionQueryFieldValue, type CollectionQueryKey, type CollectionQueryOperator, type CollectionQueryValue, type CollectionSchema, type ContentAgentAppPageConfig, type ContentAgentAppPageContext, type ContentAgentCollectionConfig, type ContentAgentConfig, type ContentAgentLocalizedValue, type ContentAgentMarkdownMetadataConfig, type ContentAgentMarkdownOptions, type ContentAgentMarkdownPolicyConfig, type ContentAgentRouteOptions, type ContentAgentSectionConfig, type ContentAgentSiteConfig, type ContentCacheArtifact, type ContentCmsCollectionConfig, type ContentCmsFieldConfig, type ContentCmsFieldType, type ContentCmsRelationConfig, type ContentCollectionConfig, type ContentCollectionHandle, type ContentCollectionI18nConfig, type ContentCollectionI18nMap, type ContentCollectionItem, type ContentCollectionItemSurroundingsOptions, type ContentCollectionKind, type ContentCollectionMap, type ContentCollectionName, type ContentCollectionNavigationOptions, type ContentCollectionPageOptions, type ContentCollectionRouteConfig, type ContentCollectionRouteMetaOptions, type ContentCollectionSearchSectionsOptions, type ContentCollectionSource, type ContentCollectionSourceObject, type ContentCollectionStringName, type ContentCollectionTarget, type ContentConfig, type ContentContext, type ContentI18nOptions, type ContentLinkRouteTarget, type ContentLinksOptions, type ContentLocaleEntry, type ContentLocaleRoute, type ContentManifest, type ContentMiniSearchOptions, type ContentNavigationItem, type ContentPageResult, type ContentPreviewOptions, type ContentProviderName, type ContentProviderSearchRequest, type ContentQueryBuilder, type ContentQueryBuilderParams, type ContentQueryBuilderWhere, type ContentQueryFetcher, type ContentQueryRequest, type ContentQuerySortFields, type ContentQuerySortOptions, type ContentQuerySortParams, type ContentReferenceSchema, type ContentResolvedMeta, type ContentRevalidateOptions, type ContentRouteMeta, type ContentSearchEngine, type ContentSearchIndexRecord, type ContentSearchOptions, type ContentSearchPublicRuntimeConfig, type ContentSearchResult, type ContentSearchSection, type ContentSelector, type ContentSeoImage, type ContentSeoMeta, type ContentSitemapAlternative, type ContentSitemapAssertOptions, type ContentSitemapAssertSitemapOptions, type ContentSitemapEntry, type ContentSitemapImage, type ContentSitemapOptions, type ContentTransformer, type ContentTreeItem, type ContentVariant, type DefineCollectionObject, type DefineCollectionOptions, type DocumentFromHandle, type LocaleFallback, type LocalePathEntry, type LocalizedContentDocument, type LocalizedDoc, type ManifestVariant, type ManyOptions, type MarkdownNode, type MarkdownOptions, type MarkdownParsedContent, type MarkdownPluginDescriptor, type MarkdownPluginOptions, type MarkdownRoot, type ModuleHooks, type ModuleOptions, type MountOptions, type NavItem, type NeighborsOptions, type NeighborsResult, type OneOptions, type PaginationOptions, type PaginationResult, type ParseContentOptions, type ParsedContent, type ParsedContentInternalMeta, type ParsedContentMeta, type PopulateFromOptions, type PopulateSpec, type PopulatedDocument, type QueryGroupBuilder, type QueryGroupFunction, type QueryMatchOperator, type QueryOperators, type QueryOrderDirection, type QueryOrderOptions, type QueryWhere, type ResolutionEnvelope, type ResolveContentReferenceOptions, type ResolveOneOptions, type ResolveOneResult, type ResolvedContentContext, type ResolvedContentI18nOptions, type ResolvedMarkdownPlugin, type ResolvedVariant, type SortDirection, type SortSpec, type StrictParsedContent, type StrictParsedContentMeta, type Toc, type TocLink, type TransformContentOptions, type TransformContentSource, type TreeOptions, type VariantsOptions } from './module.mjs'
11
+ export { type AgentMetadataField, type AgentMetadataFieldList, type BacklinkFields, type BacklinkSource, type BacklinksOptions, type BacklinksResult, type CollectionQueryBuilder, type CollectionQueryField, type CollectionQueryFieldValue, type CollectionQueryKey, type CollectionQueryOperator, type CollectionQueryValue, type CollectionSchema, type ContentAgentAppPageConfig, type ContentAgentAppPageContext, type ContentAgentCollectionConfig, type ContentAgentConfig, type ContentAgentLocalizedValue, type ContentAgentMarkdownMetadataConfig, type ContentAgentMarkdownOptions, type ContentAgentMarkdownPolicyConfig, type ContentAgentRouteOptions, type ContentAgentRuntimeAppPageConfig, type ContentAgentRuntimeConfig, type ContentAgentSectionConfig, type ContentAgentSiteConfig, type ContentCacheArtifact, type ContentCmsCollectionConfig, type ContentCmsFieldConfig, type ContentCmsFieldType, type ContentCmsRelationConfig, type ContentCollectionConfig, type ContentCollectionHandle, type ContentCollectionI18nConfig, type ContentCollectionI18nMap, type ContentCollectionItem, type ContentCollectionItemSurroundingsOptions, type ContentCollectionKind, type ContentCollectionMap, type ContentCollectionName, type ContentCollectionNavigationOptions, type ContentCollectionPageOptions, type ContentCollectionRouteConfig, type ContentCollectionRouteMetaOptions, type ContentCollectionSearchSectionsOptions, type ContentCollectionSource, type ContentCollectionSourceObject, type ContentCollectionStringName, type ContentCollectionTarget, type ContentConfig, type ContentContext, type ContentI18nOptions, type ContentLinkRouteTarget, type ContentLinksOptions, type ContentLocaleEntry, type ContentLocaleRoute, type ContentManifest, type ContentMiniSearchOptions, type ContentNavigationItem, type ContentPageResult, type ContentPreviewOptions, type ContentProviderName, type ContentProviderSearchRequest, type ContentQueryBuilder, type ContentQueryBuilderParams, type ContentQueryBuilderWhere, type ContentQueryFetcher, type ContentQueryRequest, type ContentQuerySortFields, type ContentQuerySortOptions, type ContentQuerySortParams, type ContentReferenceSchema, type ContentResolvedMeta, type ContentRevalidateOptions, type ContentRouteMeta, type ContentSearchEngine, type ContentSearchIndexRecord, type ContentSearchOptions, type ContentSearchPublicRuntimeConfig, type ContentSearchResult, type ContentSearchSection, type ContentSelector, type ContentSeoImage, type ContentSeoMeta, type ContentSitemapAlternative, type ContentSitemapAssertOptions, type ContentSitemapAssertSitemapOptions, type ContentSitemapEntry, type ContentSitemapImage, type ContentSitemapOptions, type ContentTransformer, type ContentTreeItem, type ContentVariant, type DefineCollectionObject, type DefineCollectionOptions, type DocumentFromHandle, type LocaleFallback, type LocalePathEntry, type LocalizedContentDocument, type LocalizedDoc, type ManifestVariant, type ManyOptions, type MarkdownNode, type MarkdownOptions, type MarkdownParsedContent, type MarkdownPluginDescriptor, type MarkdownPluginOptions, type MarkdownRoot, type ModuleHooks, type ModuleOptions, type MountOptions, type NavItem, type NeighborsOptions, type NeighborsResult, type OneOptions, type PaginationOptions, type PaginationResult, type ParseContentOptions, type ParsedContent, type ParsedContentInternalMeta, type ParsedContentMeta, type PopulateFromOptions, type PopulateSpec, type PopulatedDocument, type QueryGroupBuilder, type QueryGroupFunction, type QueryMatchOperator, type QueryOperators, type QueryOrderDirection, type QueryOrderOptions, type QueryWhere, type ResolutionEnvelope, type ResolveContentReferenceOptions, type ResolveOneOptions, type ResolveOneResult, type ResolvedContentContext, type ResolvedContentI18nOptions, type ResolvedMarkdownPlugin, type ResolvedVariant, type SortDirection, type SortSpec, type StrictParsedContent, type StrictParsedContentMeta, type Toc, type TocLink, type TransformContentOptions, type TransformContentSource, type TreeOptions, type VariantsOptions } from './module.mjs'
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "@lupinum/ginko-content",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lupinum/ginko-content",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Collection-first content engine for Nuxt",
5
5
  "homepage": "https://ginko-content.nuxt.dev",
6
6
  "bugs": {