@lupinum/ginko-content 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/compatibility.json +27 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +690 -0
- package/dist/cms-contract/build +1 -0
- package/dist/cms-contract/build.d.ts +44 -0
- package/dist/cms-contract/build.js +513 -0
- package/dist/cms-contract/index +1 -0
- package/dist/cms-contract/index.d.ts +25 -0
- package/dist/cms-contract/index.js +37 -0
- package/dist/cms-contract/mdc +1 -0
- package/dist/cms-contract/mdc.d.ts +32 -0
- package/dist/cms-contract/mdc.js +52 -0
- package/dist/cms-contract/path +1 -0
- package/dist/cms-contract/path.d.ts +12 -0
- package/dist/cms-contract/path.js +18 -0
- package/dist/cms-contract/schema +1 -0
- package/dist/cms-contract/schema.d.ts +18 -0
- package/dist/cms-contract/schema.js +13 -0
- package/dist/cms-contract/types +1 -0
- package/dist/cms-contract/types.d.ts +177 -0
- package/dist/cms-contract/types.js +0 -0
- package/dist/cms-import/index +1 -0
- package/dist/cms-import/index.d.ts +21 -0
- package/dist/cms-import/index.js +57 -0
- package/dist/config.d.mts +3 -0
- package/dist/config.mjs +3 -0
- package/dist/core/cache +1 -0
- package/dist/core/cache-hints +1 -0
- package/dist/core/cache-hints.d.ts +3 -0
- package/dist/core/cache-hints.js +55 -0
- package/dist/core/cache.d.ts +29 -0
- package/dist/core/cache.js +0 -0
- package/dist/core/content/collection +1 -0
- package/dist/core/content/collection.d.ts +3 -0
- package/dist/core/content/collection.js +52 -0
- package/dist/core/content/graph +1 -0
- package/dist/core/content/graph.d.ts +147 -0
- package/dist/core/content/graph.js +189 -0
- package/dist/core/content/ignore +1 -0
- package/dist/core/content/ignore.d.ts +5 -0
- package/dist/core/content/ignore.js +10 -0
- package/dist/core/content/locale +1 -0
- package/dist/core/content/locale.d.ts +61 -0
- package/dist/core/content/locale.js +77 -0
- package/dist/core/content/path +1 -0
- package/dist/core/content/path.d.ts +36 -0
- package/dist/core/content/path.js +143 -0
- package/dist/core/content/slug +1 -0
- package/dist/core/content/slug.d.ts +4 -0
- package/dist/core/content/slug.js +41 -0
- package/dist/core/content/sources +1 -0
- package/dist/core/content/sources.d.ts +2 -0
- package/dist/core/content/sources.js +6 -0
- package/dist/core/errors +1 -0
- package/dist/core/errors.d.ts +15 -0
- package/dist/core/errors.js +10 -0
- package/dist/core/markdown/tree +1 -0
- package/dist/core/markdown/tree.d.ts +9 -0
- package/dist/core/markdown/tree.js +47 -0
- package/dist/core/query/builder +1 -0
- package/dist/core/query/builder.d.ts +18 -0
- package/dist/core/query/builder.js +186 -0
- package/dist/core/query/execute +1 -0
- package/dist/core/query/execute.d.ts +52 -0
- package/dist/core/query/execute.js +304 -0
- package/dist/core/query/filter +1 -0
- package/dist/core/query/filter.d.ts +42 -0
- package/dist/core/query/filter.js +118 -0
- package/dist/core/query/json +1 -0
- package/dist/core/query/json.d.ts +2 -0
- package/dist/core/query/json.js +20 -0
- package/dist/core/query/lower +1 -0
- package/dist/core/query/lower.d.ts +14 -0
- package/dist/core/query/lower.js +121 -0
- package/dist/core/query/operators +1 -0
- package/dist/core/query/operators.d.ts +23 -0
- package/dist/core/query/operators.js +126 -0
- package/dist/core/query/params +1 -0
- package/dist/core/query/params.d.ts +15 -0
- package/dist/core/query/params.js +83 -0
- package/dist/core/query/plan +1 -0
- package/dist/core/query/plan.d.ts +110 -0
- package/dist/core/query/plan.js +0 -0
- package/dist/core/references/resolve +1 -0
- package/dist/core/references/resolve.d.ts +31 -0
- package/dist/core/references/resolve.js +121 -0
- package/dist/core/references/schema +1 -0
- package/dist/core/references/schema.d.ts +8 -0
- package/dist/core/references/schema.js +70 -0
- package/dist/core/result +1 -0
- package/dist/core/result.d.ts +27 -0
- package/dist/core/result.js +2 -0
- package/dist/features/collections/resolve +1 -0
- package/dist/features/collections/resolve.d.ts +63 -0
- package/dist/features/collections/resolve.js +76 -0
- package/dist/features/localization/config +1 -0
- package/dist/features/localization/config.d.ts +18 -0
- package/dist/features/localization/config.js +25 -0
- package/dist/features/localization/links +1 -0
- package/dist/features/localization/links.d.ts +1 -0
- package/dist/features/localization/links.js +69 -0
- package/dist/features/localization/path +1 -0
- package/dist/features/localization/path.d.ts +32 -0
- package/dist/features/localization/path.js +80 -0
- package/dist/features/localization/results +1 -0
- package/dist/features/localization/results.d.ts +42 -0
- package/dist/features/localization/results.js +149 -0
- package/dist/features/localization/translated-slugs +1 -0
- package/dist/features/localization/translated-slugs.d.ts +11 -0
- package/dist/features/localization/translated-slugs.js +80 -0
- package/dist/features/navigation/build +1 -0
- package/dist/features/navigation/build.d.ts +28 -0
- package/dist/features/navigation/build.js +104 -0
- package/dist/features/navigation/canonical +1 -0
- package/dist/features/navigation/canonical.d.ts +33 -0
- package/dist/features/navigation/canonical.js +149 -0
- package/dist/features/navigation/query +1 -0
- package/dist/features/navigation/query.d.ts +19 -0
- package/dist/features/navigation/query.js +51 -0
- package/dist/features/navigation/resolve +1 -0
- package/dist/features/navigation/resolve.d.ts +20 -0
- package/dist/features/navigation/resolve.js +79 -0
- package/dist/features/navigation/tree +1 -0
- package/dist/features/navigation/tree.d.ts +6 -0
- package/dist/features/navigation/tree.js +32 -0
- package/dist/features/search/navigation +1 -0
- package/dist/features/search/navigation.d.ts +6 -0
- package/dist/features/search/navigation.js +21 -0
- package/dist/features/search/sections +1 -0
- package/dist/features/search/sections.d.ts +21 -0
- package/dist/features/search/sections.js +98 -0
- package/dist/features/sitemap/query +1 -0
- package/dist/features/sitemap/query.d.ts +68 -0
- package/dist/features/sitemap/query.js +171 -0
- package/dist/integrations/nitro/context +1 -0
- package/dist/integrations/nitro/context.d.ts +63 -0
- package/dist/integrations/nitro/context.js +28 -0
- package/dist/integrations/nitro/ingest +1 -0
- package/dist/integrations/nitro/ingest.d.ts +18 -0
- package/dist/integrations/nitro/ingest.js +120 -0
- package/dist/integrations/nitro/preview +1 -0
- package/dist/integrations/nitro/preview.d.ts +5 -0
- package/dist/integrations/nitro/preview.js +21 -0
- package/dist/integrations/nitro/runtime-config +1 -0
- package/dist/integrations/nitro/runtime-config.d.ts +1 -0
- package/dist/integrations/nitro/runtime-config.js +4 -0
- package/dist/integrations/nitro/storage +1 -0
- package/dist/integrations/nitro/storage.d.ts +9 -0
- package/dist/integrations/nitro/storage.js +113 -0
- package/dist/integrations/vue/content-components +1 -0
- package/dist/integrations/vue/content-components.d.ts +24 -0
- package/dist/integrations/vue/content-components.js +67 -0
- package/dist/integrations/vue/html-tags +1 -0
- package/dist/integrations/vue/html-tags.d.ts +2 -0
- package/dist/integrations/vue/html-tags.js +119 -0
- package/dist/integrations/vue/markdown-refs +1 -0
- package/dist/integrations/vue/markdown-refs.d.ts +1 -0
- package/dist/integrations/vue/markdown-refs.js +1 -0
- package/dist/module.d.mts +2044 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +1381 -0
- package/dist/parsers/csv +1 -0
- package/dist/parsers/csv.d.ts +2 -0
- package/dist/parsers/csv.js +38 -0
- package/dist/parsers/from-csv +1 -0
- package/dist/parsers/from-csv.d.ts +20 -0
- package/dist/parsers/from-csv.js +85 -0
- package/dist/parsers/index +1 -0
- package/dist/parsers/index.d.ts +10 -0
- package/dist/parsers/index.js +50 -0
- package/dist/parsers/json +1 -0
- package/dist/parsers/json.d.ts +2 -0
- package/dist/parsers/json.js +29 -0
- package/dist/parsers/markdown +1 -0
- package/dist/parsers/markdown-plugins +1 -0
- package/dist/parsers/markdown-plugins.d.ts +3 -0
- package/dist/parsers/markdown-plugins.js +58 -0
- package/dist/parsers/markdown.d.ts +2 -0
- package/dist/parsers/markdown.js +64 -0
- package/dist/parsers/path-meta +1 -0
- package/dist/parsers/path-meta.d.ts +4 -0
- package/dist/parsers/path-meta.js +37 -0
- package/dist/parsers/utils +1 -0
- package/dist/parsers/utils.d.ts +2 -0
- package/dist/parsers/utils.js +3 -0
- package/dist/parsers/yaml +1 -0
- package/dist/parsers/yaml.d.ts +2 -0
- package/dist/parsers/yaml.js +19 -0
- package/dist/public/client +1 -0
- package/dist/public/client.d.ts +19 -0
- package/dist/public/client.js +26 -0
- package/dist/public/provider +1 -0
- package/dist/public/provider-errors +1 -0
- package/dist/public/provider-errors.d.ts +4 -0
- package/dist/public/provider-errors.js +28 -0
- package/dist/public/provider.d.ts +74 -0
- package/dist/public/provider.js +6 -0
- package/dist/public/server +1 -0
- package/dist/public/server.d.ts +19 -0
- package/dist/public/server.js +28 -0
- package/dist/runtime/app/components/ContentRenderer.d.vue.ts +62 -0
- package/dist/runtime/app/components/ContentRenderer.vue +84 -0
- package/dist/runtime/app/components/ContentRenderer.vue.d.ts +62 -0
- package/dist/runtime/app/components/ContentRendererInline.d.vue.ts +50 -0
- package/dist/runtime/app/components/ContentRendererInline.vue +97 -0
- package/dist/runtime/app/components/ContentRendererInline.vue.d.ts +50 -0
- package/dist/runtime/app/components/Prose/ProseCode.d.vue.ts +61 -0
- package/dist/runtime/app/components/Prose/ProseCode.vue +32 -0
- package/dist/runtime/app/components/Prose/ProseCode.vue.d.ts +61 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.d.vue.ts +13 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.vue +3 -0
- package/dist/runtime/app/components/Prose/ProseCodeInline.vue.d.ts +13 -0
- package/dist/runtime/app/components/Prose/ProseImg.d.vue.ts +59 -0
- package/dist/runtime/app/components/Prose/ProseImg.vue +59 -0
- package/dist/runtime/app/components/Prose/ProseImg.vue.d.ts +59 -0
- package/dist/runtime/app/components/Prose/ProsePre.d.vue.ts +79 -0
- package/dist/runtime/app/components/Prose/ProsePre.vue +42 -0
- package/dist/runtime/app/components/Prose/ProsePre.vue.d.ts +79 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.d.vue.ts +68 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue +99 -0
- package/dist/runtime/app/components/internal/ContentRendererMarkdown.vue.d.ts +68 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer +1 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer.d.ts +90 -0
- package/dist/runtime/app/components/internal/MarkdownRenderer.js +191 -0
- package/dist/runtime/app/composables/async-data +1 -0
- package/dist/runtime/app/composables/async-data.d.ts +2 -0
- package/dist/runtime/app/composables/async-data.js +4 -0
- package/dist/runtime/app/composables/content-i18n +1 -0
- package/dist/runtime/app/composables/content-i18n.d.ts +5 -0
- package/dist/runtime/app/composables/content-i18n.js +1 -0
- package/dist/runtime/app/composables/head +1 -0
- package/dist/runtime/app/composables/head.d.ts +11 -0
- package/dist/runtime/app/composables/head.js +98 -0
- package/dist/runtime/app/composables/locale +1 -0
- package/dist/runtime/app/composables/locale-context +1 -0
- package/dist/runtime/app/composables/locale-context.d.ts +5 -0
- package/dist/runtime/app/composables/locale-context.js +8 -0
- package/dist/runtime/app/composables/locale.d.ts +8 -0
- package/dist/runtime/app/composables/locale.js +15 -0
- package/dist/runtime/app/composables/navigation +1 -0
- package/dist/runtime/app/composables/navigation.d.ts +3 -0
- package/dist/runtime/app/composables/navigation.js +7 -0
- package/dist/runtime/app/composables/preview +1 -0
- package/dist/runtime/app/composables/preview.d.ts +5 -0
- package/dist/runtime/app/composables/preview.js +52 -0
- package/dist/runtime/app/composables/query-api +1 -0
- package/dist/runtime/app/composables/query-api.d.ts +27 -0
- package/dist/runtime/app/composables/query-api.js +46 -0
- package/dist/runtime/app/composables/route +1 -0
- package/dist/runtime/app/composables/route.d.ts +11 -0
- package/dist/runtime/app/composables/route.js +150 -0
- package/dist/runtime/app/composables/runtime +1 -0
- package/dist/runtime/app/composables/runtime.d.ts +2 -0
- package/dist/runtime/app/composables/runtime.js +7 -0
- package/dist/runtime/app/composables/search +1 -0
- package/dist/runtime/app/composables/search.d.ts +58 -0
- package/dist/runtime/app/composables/search.js +321 -0
- package/dist/runtime/app/composables/site-data +1 -0
- package/dist/runtime/app/composables/site-data.d.ts +12 -0
- package/dist/runtime/app/composables/site-data.js +12 -0
- package/dist/runtime/app/composables/toc +1 -0
- package/dist/runtime/app/composables/toc.d.ts +10 -0
- package/dist/runtime/app/composables/toc.js +31 -0
- package/dist/runtime/app/composables/use-content +1 -0
- package/dist/runtime/app/composables/use-content.d.ts +188 -0
- package/dist/runtime/app/composables/use-content.js +307 -0
- package/dist/runtime/app/composables/useUnwrap +1 -0
- package/dist/runtime/app/composables/useUnwrap.d.ts +8 -0
- package/dist/runtime/app/composables/useUnwrap.js +35 -0
- package/dist/runtime/app/composables/utils +1 -0
- package/dist/runtime/app/composables/utils.d.ts +22 -0
- package/dist/runtime/app/composables/utils.js +76 -0
- package/dist/runtime/app/composables/web-socket +1 -0
- package/dist/runtime/app/composables/web-socket.d.ts +3 -0
- package/dist/runtime/app/composables/web-socket.js +65 -0
- package/dist/runtime/app/pages/content.d.vue.ts +3 -0
- package/dist/runtime/app/pages/content.vue +14 -0
- package/dist/runtime/app/pages/content.vue.d.ts +3 -0
- package/dist/runtime/app/plugins/markdown-components +1 -0
- package/dist/runtime/app/plugins/markdown-components.d.ts +2 -0
- package/dist/runtime/app/plugins/markdown-components.js +19 -0
- package/dist/runtime/app/plugins/ws +1 -0
- package/dist/runtime/app/plugins/ws.d.ts +2 -0
- package/dist/runtime/app/plugins/ws.js +7 -0
- package/dist/runtime/app.d.vue.ts +3 -0
- package/dist/runtime/app.vue +3 -0
- package/dist/runtime/app.vue.d.ts +3 -0
- package/dist/runtime/markdown/plugins +1 -0
- package/dist/runtime/markdown/plugins.d.ts +3 -0
- package/dist/runtime/markdown/plugins.js +39 -0
- package/dist/runtime/query/public-limits +1 -0
- package/dist/runtime/query/public-limits.d.ts +2 -0
- package/dist/runtime/query/public-limits.js +2 -0
- package/dist/runtime/query/resolve +1 -0
- package/dist/runtime/query/resolve.d.ts +5 -0
- package/dist/runtime/query/resolve.js +9 -0
- package/dist/runtime/query/routes +1 -0
- package/dist/runtime/query/routes.d.ts +33 -0
- package/dist/runtime/query/routes.js +21 -0
- package/dist/runtime/query/unified +1 -0
- package/dist/runtime/query/unified.d.ts +94 -0
- package/dist/runtime/query/unified.js +473 -0
- package/dist/runtime/server/api/cache +1 -0
- package/dist/runtime/server/api/cache.d.ts +8 -0
- package/dist/runtime/server/api/cache.js +26 -0
- package/dist/runtime/server/api/locales +1 -0
- package/dist/runtime/server/api/locales.d.ts +6 -0
- package/dist/runtime/server/api/locales.js +28 -0
- package/dist/runtime/server/api/navigation +1 -0
- package/dist/runtime/server/api/navigation.d.ts +2 -0
- package/dist/runtime/server/api/navigation.js +21 -0
- package/dist/runtime/server/api/query +1 -0
- package/dist/runtime/server/api/query.d.ts +2 -0
- package/dist/runtime/server/api/query.js +6 -0
- package/dist/runtime/server/api/revalidate +1 -0
- package/dist/runtime/server/api/revalidate.d.ts +6 -0
- package/dist/runtime/server/api/revalidate.js +156 -0
- package/dist/runtime/server/api/search +1 -0
- package/dist/runtime/server/api/search-index +1 -0
- package/dist/runtime/server/api/search-index.d.ts +2 -0
- package/dist/runtime/server/api/search-index.js +20 -0
- package/dist/runtime/server/api/search.d.ts +2 -0
- package/dist/runtime/server/api/search.js +40 -0
- package/dist/runtime/server/api/site-data +1 -0
- package/dist/runtime/server/api/site-data.d.ts +2 -0
- package/dist/runtime/server/api/site-data.js +22 -0
- package/dist/runtime/server/api/sitemap +1 -0
- package/dist/runtime/server/api/sitemap.d.ts +2 -0
- package/dist/runtime/server/api/sitemap.js +11 -0
- package/dist/runtime/server/cache-adapter +1 -0
- package/dist/runtime/server/cache-adapter.d.ts +2 -0
- package/dist/runtime/server/cache-adapter.js +11 -0
- package/dist/runtime/server/cache-adapters +1 -0
- package/dist/runtime/server/cache-adapters.d.ts +9 -0
- package/dist/runtime/server/cache-adapters.js +50 -0
- package/dist/runtime/server/cache-hints +1 -0
- package/dist/runtime/server/cache-hints.d.ts +5 -0
- package/dist/runtime/server/cache-hints.js +17 -0
- package/dist/runtime/server/collection-helpers +1 -0
- package/dist/runtime/server/collection-helpers.d.ts +13 -0
- package/dist/runtime/server/collection-helpers.js +99 -0
- package/dist/runtime/server/index +1 -0
- package/dist/runtime/server/index.d.ts +9 -0
- package/dist/runtime/server/index.js +15 -0
- package/dist/runtime/server/manifest +1 -0
- package/dist/runtime/server/manifest.d.ts +1 -0
- package/dist/runtime/server/manifest.js +1 -0
- package/dist/runtime/server/navigation +1 -0
- package/dist/runtime/server/navigation-query +1 -0
- package/dist/runtime/server/navigation-query.d.ts +4 -0
- package/dist/runtime/server/navigation-query.js +80 -0
- package/dist/runtime/server/navigation.d.ts +2 -0
- package/dist/runtime/server/navigation.js +9 -0
- package/dist/runtime/server/pagefind +1 -0
- package/dist/runtime/server/pagefind.d.ts +2 -0
- package/dist/runtime/server/pagefind.js +30 -0
- package/dist/runtime/server/plugins/cache +1 -0
- package/dist/runtime/server/plugins/cache.d.ts +2 -0
- package/dist/runtime/server/plugins/cache.js +17 -0
- package/dist/runtime/server/plugins/sitemap +1 -0
- package/dist/runtime/server/plugins/sitemap.d.ts +2 -0
- package/dist/runtime/server/plugins/sitemap.js +25 -0
- package/dist/runtime/server/preview +1 -0
- package/dist/runtime/server/preview.d.ts +1 -0
- package/dist/runtime/server/preview.js +1 -0
- package/dist/runtime/server/provider-query +1 -0
- package/dist/runtime/server/provider-query.d.ts +27 -0
- package/dist/runtime/server/provider-query.js +131 -0
- package/dist/runtime/server/provider-result +1 -0
- package/dist/runtime/server/provider-result.d.ts +10 -0
- package/dist/runtime/server/provider-result.js +30 -0
- package/dist/runtime/server/providers/filesystem +1 -0
- package/dist/runtime/server/providers/filesystem.d.ts +2 -0
- package/dist/runtime/server/providers/filesystem.js +47 -0
- package/dist/runtime/server/providers/index +1 -0
- package/dist/runtime/server/providers/index.d.ts +3 -0
- package/dist/runtime/server/providers/index.js +190 -0
- package/dist/runtime/server/query-api +1 -0
- package/dist/runtime/server/query-api.d.ts +28 -0
- package/dist/runtime/server/query-api.js +54 -0
- package/dist/runtime/server/query-executor +1 -0
- package/dist/runtime/server/query-executor.d.ts +4 -0
- package/dist/runtime/server/query-executor.js +121 -0
- package/dist/runtime/server/runtime-config +1 -0
- package/dist/runtime/server/runtime-config.d.ts +1 -0
- package/dist/runtime/server/runtime-config.js +1 -0
- package/dist/runtime/server/search +1 -0
- package/dist/runtime/server/search.d.ts +18 -0
- package/dist/runtime/server/search.js +134 -0
- package/dist/runtime/server/sitemap +1 -0
- package/dist/runtime/server/sitemap-provider +1 -0
- package/dist/runtime/server/sitemap-provider.d.ts +10 -0
- package/dist/runtime/server/sitemap-provider.js +11 -0
- package/dist/runtime/server/sitemap.d.ts +6 -0
- package/dist/runtime/server/sitemap.js +45 -0
- package/dist/runtime/server/storage +1 -0
- package/dist/runtime/server/storage-access +1 -0
- package/dist/runtime/server/storage-access.d.ts +1 -0
- package/dist/runtime/server/storage-access.js +9 -0
- package/dist/runtime/server/storage.d.ts +2 -0
- package/dist/runtime/server/storage.js +2 -0
- package/dist/runtime/server/validation +1 -0
- package/dist/runtime/server/validation.d.ts +1 -0
- package/dist/runtime/server/validation.js +6 -0
- package/dist/runtime/shared/search +1 -0
- package/dist/runtime/shared/search.d.ts +2 -0
- package/dist/runtime/shared/search.js +89 -0
- package/dist/runtime/transformers/component-resolver +1 -0
- package/dist/runtime/transformers/component-resolver.d.ts +10 -0
- package/dist/runtime/transformers/component-resolver.js +30 -0
- package/dist/runtime/transformers/csv/from-csv +1 -0
- package/dist/runtime/transformers/csv/from-csv.d.ts +1 -0
- package/dist/runtime/transformers/csv/from-csv.js +1 -0
- package/dist/runtime/transformers/csv/index +1 -0
- package/dist/runtime/transformers/csv/index.d.ts +1 -0
- package/dist/runtime/transformers/csv/index.js +1 -0
- package/dist/runtime/transformers/define +1 -0
- package/dist/runtime/transformers/define.d.ts +1 -0
- package/dist/runtime/transformers/define.js +1 -0
- package/dist/runtime/transformers/index +1 -0
- package/dist/runtime/transformers/index.d.ts +1 -0
- package/dist/runtime/transformers/index.js +1 -0
- package/dist/runtime/transformers/json +1 -0
- package/dist/runtime/transformers/json.d.ts +1 -0
- package/dist/runtime/transformers/json.js +1 -0
- package/dist/runtime/transformers/markdown +1 -0
- package/dist/runtime/transformers/markdown.d.ts +1 -0
- package/dist/runtime/transformers/markdown.js +1 -0
- package/dist/runtime/transformers/path-meta +1 -0
- package/dist/runtime/transformers/path-meta.d.ts +2 -0
- package/dist/runtime/transformers/path-meta.js +2 -0
- package/dist/runtime/transformers/utils +1 -0
- package/dist/runtime/transformers/utils.d.ts +1 -0
- package/dist/runtime/transformers/utils.js +1 -0
- package/dist/runtime/transformers/yaml +1 -0
- package/dist/runtime/transformers/yaml.d.ts +1 -0
- package/dist/runtime/transformers/yaml.js +1 -0
- package/dist/runtime/utils/content-components +1 -0
- package/dist/runtime/utils/content-components.d.ts +9 -0
- package/dist/runtime/utils/content-components.js +16 -0
- package/dist/runtime/utils/query +1 -0
- package/dist/runtime/utils/query.d.ts +5 -0
- package/dist/runtime/utils/query.js +18 -0
- package/dist/runtime/virtual/transformers.d.ts +4 -0
- package/dist/runtime/virtual.d.ts +7 -0
- package/dist/storage/cache +1 -0
- package/dist/storage/cache.d.ts +32 -0
- package/dist/storage/cache.js +42 -0
- package/dist/storage/content +1 -0
- package/dist/storage/content.d.ts +41 -0
- package/dist/storage/content.js +86 -0
- package/dist/storage/contents +1 -0
- package/dist/storage/contents.d.ts +5 -0
- package/dist/storage/contents.js +116 -0
- package/dist/storage/driver +1 -0
- package/dist/storage/driver.d.ts +28 -0
- package/dist/storage/driver.js +22 -0
- package/dist/storage/graph +1 -0
- package/dist/storage/graph.d.ts +3 -0
- package/dist/storage/graph.js +14 -0
- package/dist/storage/manifest +1 -0
- package/dist/storage/manifest.d.ts +18 -0
- package/dist/storage/manifest.js +68 -0
- package/dist/storage/references +1 -0
- package/dist/storage/references.d.ts +13 -0
- package/dist/storage/references.js +78 -0
- package/dist/storage/validation +1 -0
- package/dist/storage/validation.d.ts +46 -0
- package/dist/storage/validation.js +341 -0
- package/dist/testing/provider-contract +1 -0
- package/dist/testing/provider-contract.d.ts +31 -0
- package/dist/testing/provider-contract.js +237 -0
- package/dist/testing/provider-fixture +1 -0
- package/dist/testing/provider-fixture.d.ts +65 -0
- package/dist/testing/provider-fixture.js +606 -0
- package/dist/types/api +1 -0
- package/dist/types/api.d.ts +47 -0
- package/dist/types/api.js +1 -0
- package/dist/types/config +1 -0
- package/dist/types/config.d.ts +281 -0
- package/dist/types/config.js +28 -0
- package/dist/types/content +1 -0
- package/dist/types/content.d.ts +311 -0
- package/dist/types/content.js +1 -0
- package/dist/types/fields +1 -0
- package/dist/types/fields.d.ts +81 -0
- package/dist/types/fields.js +146 -0
- package/dist/types/index +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +6 -0
- package/dist/types/module +1 -0
- package/dist/types/module.d.ts +428 -0
- package/dist/types/module.js +0 -0
- package/dist/types/picomatch.d.ts +8 -0
- package/dist/types/query +1 -0
- package/dist/types/query.d.ts +862 -0
- package/dist/types/query.js +1 -0
- package/dist/types/reference +1 -0
- package/dist/types/reference.d.ts +1 -0
- package/dist/types/reference.js +1 -0
- package/dist/types/runtime +1 -0
- package/dist/types/runtime.d.ts +45 -0
- package/dist/types/runtime.js +1 -0
- package/dist/types/search +1 -0
- package/dist/types/search.d.ts +64 -0
- package/dist/types/search.js +0 -0
- package/dist/types/virtual.d.ts +19 -0
- package/dist/types.d.mts +11 -0
- package/dist/web-types.json +466 -0
- package/package.json +135 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The content graph is the precomputed, read-only index every query reads
|
|
3
|
+
* from. `buildContentGraph(documents)` turns a flat list of parsed content
|
|
4
|
+
* into the cross-referenced lookup tables below.
|
|
5
|
+
*
|
|
6
|
+
* Key concepts:
|
|
7
|
+
*
|
|
8
|
+
* - **Canonical key**: the locale-independent identity of a document. Two
|
|
9
|
+
* locale variants of the same page share the same canonical key; the
|
|
10
|
+
* key is what refs point at and what navigation deduplicates on.
|
|
11
|
+
* - **`byId`**: lookup by the fully-qualified, locale-suffixed content id.
|
|
12
|
+
* One entry per file-on-disk variant.
|
|
13
|
+
* - **`byCanonical`**: the core locale-aware index. `byCanonical[key]` is
|
|
14
|
+
* a `{ [locale]: variant }` map so resolving a page in a given locale
|
|
15
|
+
* is an O(1) lookup rather than a linear scan.
|
|
16
|
+
* - **`byRoute`**: route path (user-visible URL) → content id. Used by the
|
|
17
|
+
* page resolver when the request arrives as a localized URL.
|
|
18
|
+
* - **`byRef`**: normalized ref string → canonical key. This is how
|
|
19
|
+
* `[link](ref:authors/evan)` finds its target without a scan.
|
|
20
|
+
* - **`referenceTargets`**: the `buildReferenceTargets` map — every shape
|
|
21
|
+
* the user might plausibly write to point at a document (canonical
|
|
22
|
+
* name, locale-prefixed path, short slug) pre-resolved to a canonical
|
|
23
|
+
* key.
|
|
24
|
+
*
|
|
25
|
+
* The graph is rebuilt from scratch on every request in dev; in production
|
|
26
|
+
* it is memoized per-request via `memoizeRuntimeValue(event, 'graph', ...)`.
|
|
27
|
+
*/
|
|
28
|
+
import type { ParsedContent } from '../../types/content';
|
|
29
|
+
import type { ContentLocaleEntry } from '../../types/query';
|
|
30
|
+
import type { ContentManifest, ManifestVariant, ResolvedVariant } from '../../types/runtime';
|
|
31
|
+
export interface ContentGraphVariant extends ManifestVariant {
|
|
32
|
+
document: ParsedContent;
|
|
33
|
+
}
|
|
34
|
+
export interface ContentGraph {
|
|
35
|
+
documents: ParsedContent[];
|
|
36
|
+
/** id → document. Keys include the locale suffix; one entry per source file. */
|
|
37
|
+
byId: Record<string, ParsedContent>;
|
|
38
|
+
/** collection name → ordered list of document ids. */
|
|
39
|
+
byCollection: Record<string, string[]>;
|
|
40
|
+
/** localized route path → list of document ids sharing that path. */
|
|
41
|
+
byPath: Record<string, string[]>;
|
|
42
|
+
/** canonical key → `{ [locale]: variant }`. The locale-aware index. */
|
|
43
|
+
byCanonical: Record<string, Record<string, ContentGraphVariant>>;
|
|
44
|
+
/** route path → content id. Used by page resolution. */
|
|
45
|
+
byRoute: Record<string, string>;
|
|
46
|
+
/** normalized ref string → canonical key. */
|
|
47
|
+
byRef: Record<string, string>;
|
|
48
|
+
/** navigation path → `{ [locale]: document }`. Drives `.navigation.yml` merging. */
|
|
49
|
+
byNavigationPath: Record<string, Record<string, ParsedContent>>;
|
|
50
|
+
/** Every user-writable reference shape pre-resolved to a canonical key. */
|
|
51
|
+
referenceTargets: Map<string, string>;
|
|
52
|
+
manifest: ContentManifest;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the locale resolution chain for a request.
|
|
56
|
+
*
|
|
57
|
+
* Order, from highest to lowest priority:
|
|
58
|
+
* 1. The explicitly requested locale (if any).
|
|
59
|
+
* 2. Author-configured fallbacks for that locale.
|
|
60
|
+
* 3. The site-wide default locale.
|
|
61
|
+
*
|
|
62
|
+
* Duplicates are removed while preserving first-occurrence order, so the
|
|
63
|
+
* caller can walk the chain and stop at the first hit without worrying
|
|
64
|
+
* about re-visiting the default.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* resolveLocaleChain('fr', 'en', { fr: ['de'] }) // ['fr', 'de', 'en']
|
|
68
|
+
* resolveLocaleChain(undefined, 'en') // ['en']
|
|
69
|
+
*/
|
|
70
|
+
export declare const resolveLocaleChain: (requestedLocale: string | undefined, defaultLocale?: string, fallback?: Record<string, string[]>) => string[];
|
|
71
|
+
/**
|
|
72
|
+
* Build a `ContentGraph` from a flat list of parsed documents.
|
|
73
|
+
*
|
|
74
|
+
* The function is pure: given the same documents it returns equivalent
|
|
75
|
+
* lookup tables. Callers memoize this per-request — see
|
|
76
|
+
* `storage/content.ts:createServerQueryFetch` and
|
|
77
|
+
* `memoizeRuntimeValue(event, 'graph', ...)`.
|
|
78
|
+
*
|
|
79
|
+
* INVARIANT: documents without `_path` are still indexed by id (so refs can
|
|
80
|
+
* find them) but are excluded from path/route/canonical lookups. Partials
|
|
81
|
+
* and navigation documents are likewise indexed by id only.
|
|
82
|
+
*/
|
|
83
|
+
export declare const buildContentGraph: (documents: ParsedContent[], options?: {
|
|
84
|
+
locales?: string[];
|
|
85
|
+
defaultLocale?: string;
|
|
86
|
+
}) => ContentGraph;
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a canonical key to a concrete locale variant.
|
|
89
|
+
*
|
|
90
|
+
* `exact: true` disables fallback — the caller only wants the requested
|
|
91
|
+
* locale, period. Without `exact`, the locale chain (requested → explicit
|
|
92
|
+
* `fallback` → configured `localeFallback` → `defaultLocale`) is walked
|
|
93
|
+
* until a variant is found.
|
|
94
|
+
*
|
|
95
|
+
* Returns `null` if the canonical key does not exist *or* if `exact` is
|
|
96
|
+
* set and the requested locale has no variant.
|
|
97
|
+
*/
|
|
98
|
+
export declare const resolveGraphVariant: (graph: ContentGraph, canonicalKey: string, requestedLocale?: string, options?: {
|
|
99
|
+
defaultLocale?: string;
|
|
100
|
+
fallback?: string[];
|
|
101
|
+
exact?: boolean;
|
|
102
|
+
localeFallback?: Record<string, string[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Restrict the locale variants considered to ones that live in this
|
|
105
|
+
* collection. Without this, a canonical key shared by two collections
|
|
106
|
+
* (e.g. `authors` and `docs` cross-referencing the same id) can resolve
|
|
107
|
+
* to a wrong-collection variant whose post-hoc filter then drops the
|
|
108
|
+
* result entirely — even though the requested collection has a perfectly
|
|
109
|
+
* good variant in another locale.
|
|
110
|
+
*/
|
|
111
|
+
collection?: string;
|
|
112
|
+
}) => ResolvedVariant | null;
|
|
113
|
+
/**
|
|
114
|
+
* Resolve a **route path** (the URL the user visited) to a locale variant.
|
|
115
|
+
*
|
|
116
|
+
* Walks the locale chain and consults `byRoute` (keyed `${locale}:${path}`)
|
|
117
|
+
* for each candidate. Falls back to scanning every locale in the graph if
|
|
118
|
+
* the chain is empty — this is what powers language-agnostic dev links
|
|
119
|
+
* where the locale has to be inferred from the content.
|
|
120
|
+
*/
|
|
121
|
+
export declare const resolveGraphRouteVariant: (graph: ContentGraph, routePath: string, requestedLocale?: string, options?: {
|
|
122
|
+
defaultLocale?: string;
|
|
123
|
+
fallback?: string[];
|
|
124
|
+
exact?: boolean;
|
|
125
|
+
localeFallback?: Record<string, string[]>;
|
|
126
|
+
collection?: string;
|
|
127
|
+
}) => ResolvedVariant | null;
|
|
128
|
+
/**
|
|
129
|
+
* Turn a user-written identity string (`'guide/intro'`, `'intro'`,
|
|
130
|
+
* `'de/leitfaden/einstieg'`) into its canonical key, optionally scoped to
|
|
131
|
+
* a collection.
|
|
132
|
+
*
|
|
133
|
+
* Consults — in order — `byCanonical` (already canonical), `byRef`
|
|
134
|
+
* (explicit `ref:` field in front-matter), then the full
|
|
135
|
+
* `referenceTargets` index (built from every plausible shape). Returns
|
|
136
|
+
* `null` if nothing matches.
|
|
137
|
+
*
|
|
138
|
+
* GOTCHA: when `collection` is provided but the collection is empty, we
|
|
139
|
+
* short-circuit to `null` rather than letting a stale canonical match
|
|
140
|
+
* leak through.
|
|
141
|
+
*/
|
|
142
|
+
export declare const resolveGraphCanonicalKey: (graph: ContentGraph, identity: string, collection?: string) => string | null;
|
|
143
|
+
export declare const resolveGraphCollectionLocales: (graph: ContentGraph, identity: string, collection?: string) => ContentLocaleEntry[];
|
|
144
|
+
export declare const selectGraphDocuments: (graph: ContentGraph, options?: {
|
|
145
|
+
collection?: string;
|
|
146
|
+
paths?: Array<string | RegExp>;
|
|
147
|
+
}) => ParsedContent[];
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { normalizeReferenceValue, buildReferenceTargets } from "../references/resolve.js";
|
|
2
|
+
const normalizePath = (path) => {
|
|
3
|
+
if (!path || path === "/") {
|
|
4
|
+
return "/";
|
|
5
|
+
}
|
|
6
|
+
return path.startsWith("/") ? path.endsWith("/") ? path.slice(0, -1) || "/" : path : `/${path.replace(/\/+$/, "")}`;
|
|
7
|
+
};
|
|
8
|
+
const emptyManifest = () => ({
|
|
9
|
+
byCanonical: {},
|
|
10
|
+
byRef: {},
|
|
11
|
+
byRoute: {},
|
|
12
|
+
paths: {},
|
|
13
|
+
collections: {}
|
|
14
|
+
});
|
|
15
|
+
export const resolveLocaleChain = (requestedLocale, defaultLocale, fallback = {}) => {
|
|
16
|
+
const chain = [
|
|
17
|
+
...requestedLocale ? [requestedLocale] : [],
|
|
18
|
+
...requestedLocale && fallback[requestedLocale] || [],
|
|
19
|
+
...defaultLocale ? [defaultLocale] : []
|
|
20
|
+
].filter(Boolean);
|
|
21
|
+
return Array.from(new Set(chain));
|
|
22
|
+
};
|
|
23
|
+
export const buildContentGraph = (documents, options = {}) => {
|
|
24
|
+
const manifest = emptyManifest();
|
|
25
|
+
const byId = {};
|
|
26
|
+
const byCanonical = {};
|
|
27
|
+
const byNavigationPath = {};
|
|
28
|
+
const defaultLocale = options.defaultLocale || "";
|
|
29
|
+
for (const document of documents) {
|
|
30
|
+
const documentId = document._id || `${document._collection || "content"}:${document._path || "document"}`;
|
|
31
|
+
byId[documentId] = document;
|
|
32
|
+
if (!document._path) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const path = normalizePath(document._path);
|
|
36
|
+
manifest.paths[path] ||= [];
|
|
37
|
+
if (document._locale === defaultLocale) {
|
|
38
|
+
manifest.paths[path].unshift(documentId);
|
|
39
|
+
} else {
|
|
40
|
+
manifest.paths[path].push(documentId);
|
|
41
|
+
}
|
|
42
|
+
if (document._collection) {
|
|
43
|
+
manifest.collections[document._collection] ||= [];
|
|
44
|
+
manifest.collections[document._collection].push(documentId);
|
|
45
|
+
}
|
|
46
|
+
if (document._navigation) {
|
|
47
|
+
const locale2 = document._locale || defaultLocale;
|
|
48
|
+
byNavigationPath[path] ||= {};
|
|
49
|
+
byNavigationPath[path][locale2] = document;
|
|
50
|
+
}
|
|
51
|
+
const isVariantDocument = !document._partial && !document._navigation && document._canonicalKey;
|
|
52
|
+
if (!isVariantDocument) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const locale = document._locale || defaultLocale;
|
|
56
|
+
const variant = {
|
|
57
|
+
canonicalKey: document._canonicalKey,
|
|
58
|
+
contentId: documentId,
|
|
59
|
+
locale,
|
|
60
|
+
path,
|
|
61
|
+
document
|
|
62
|
+
};
|
|
63
|
+
manifest.byCanonical[document._canonicalKey] ||= {};
|
|
64
|
+
manifest.byCanonical[document._canonicalKey][locale] = variant;
|
|
65
|
+
manifest.byRoute[`${locale}:${path}`] = document._canonicalKey;
|
|
66
|
+
if (document._type === "markdown" && typeof document.ref === "string" && document.ref.length) {
|
|
67
|
+
manifest.byRef[document.ref] = document._canonicalKey;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const [canonicalKey, variants] of Object.entries(manifest.byCanonical)) {
|
|
71
|
+
byCanonical[canonicalKey] = Object.fromEntries(
|
|
72
|
+
Object.entries(variants).map(([locale, variant]) => [
|
|
73
|
+
locale,
|
|
74
|
+
{
|
|
75
|
+
...variant,
|
|
76
|
+
document: byId[variant.contentId]
|
|
77
|
+
}
|
|
78
|
+
])
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
documents,
|
|
83
|
+
byId,
|
|
84
|
+
byCollection: manifest.collections,
|
|
85
|
+
byPath: manifest.paths,
|
|
86
|
+
byCanonical,
|
|
87
|
+
byRoute: manifest.byRoute,
|
|
88
|
+
byRef: manifest.byRef,
|
|
89
|
+
byNavigationPath,
|
|
90
|
+
referenceTargets: buildReferenceTargets(documents.filter((document) => !document._partial && !document._navigation), options.locales || []),
|
|
91
|
+
manifest
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export const resolveGraphVariant = (graph, canonicalKey, requestedLocale, options = {}) => {
|
|
95
|
+
const variants = graph.byCanonical[canonicalKey];
|
|
96
|
+
if (!variants) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const collectionIds = options.collection ? new Set(graph.byCollection[options.collection] || []) : null;
|
|
100
|
+
const scopedVariants = collectionIds ? Object.fromEntries(Object.entries(variants).filter(([, v]) => collectionIds.has(v.contentId))) : variants;
|
|
101
|
+
if (!Object.keys(scopedVariants).length) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const availableLocales = Object.keys(scopedVariants);
|
|
105
|
+
const localeChain = options.exact ? requestedLocale ? [requestedLocale] : [] : options.fallback?.length ? Array.from(new Set([requestedLocale, ...options.fallback].filter(Boolean))) : resolveLocaleChain(requestedLocale, options.defaultLocale, options.localeFallback || {});
|
|
106
|
+
const resolvedLocale = localeChain.find((locale) => scopedVariants[locale]) || (options.exact ? void 0 : availableLocales[0]);
|
|
107
|
+
if (resolvedLocale === void 0) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const variant = scopedVariants[resolvedLocale];
|
|
111
|
+
return {
|
|
112
|
+
canonicalKey,
|
|
113
|
+
contentId: variant.contentId,
|
|
114
|
+
locale: variant.locale,
|
|
115
|
+
path: variant.path,
|
|
116
|
+
requestedLocale,
|
|
117
|
+
resolvedLocale,
|
|
118
|
+
fallback: Boolean(requestedLocale && resolvedLocale !== requestedLocale),
|
|
119
|
+
availableLocales
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export const resolveGraphRouteVariant = (graph, routePath, requestedLocale, options = {}) => {
|
|
123
|
+
const normalizedPath = normalizePath(routePath);
|
|
124
|
+
const localeChain = options.exact ? requestedLocale ? [requestedLocale] : [] : options.fallback?.length ? Array.from(new Set([requestedLocale, ...options.fallback].filter(Boolean))) : resolveLocaleChain(requestedLocale, options.defaultLocale, options.localeFallback || {});
|
|
125
|
+
const localesToSearch = localeChain.length ? localeChain : Array.from(new Set(Object.values(graph.byCanonical).flatMap((variants) => Object.keys(variants))));
|
|
126
|
+
for (const locale of localesToSearch) {
|
|
127
|
+
const canonicalKey = graph.byRoute[`${locale}:${normalizedPath}`];
|
|
128
|
+
if (!canonicalKey) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const variant = resolveGraphVariant(graph, canonicalKey, requestedLocale, options);
|
|
132
|
+
if (variant) return variant;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
};
|
|
136
|
+
export const resolveGraphCanonicalKey = (graph, identity, collection) => {
|
|
137
|
+
const normalizedIdentity = normalizeReferenceValue(identity);
|
|
138
|
+
if (!normalizedIdentity) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const hasCollectionVariant = (canonicalKey) => {
|
|
142
|
+
if (!collection) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
const collectionIds = new Set(graph.byCollection[collection] || []);
|
|
146
|
+
return Object.values(graph.byCanonical[canonicalKey] || {}).some((variant) => collectionIds.has(variant.contentId));
|
|
147
|
+
};
|
|
148
|
+
if (graph.byCanonical[normalizedIdentity] && hasCollectionVariant(normalizedIdentity)) {
|
|
149
|
+
return normalizedIdentity;
|
|
150
|
+
}
|
|
151
|
+
const refCanonicalKey = graph.byRef[normalizedIdentity];
|
|
152
|
+
if (refCanonicalKey && hasCollectionVariant(refCanonicalKey)) {
|
|
153
|
+
return refCanonicalKey;
|
|
154
|
+
}
|
|
155
|
+
if (collection && !(graph.byCollection[collection] || []).length) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const targetCanonicalKey = graph.referenceTargets.get(normalizedIdentity);
|
|
159
|
+
return targetCanonicalKey && hasCollectionVariant(targetCanonicalKey) ? targetCanonicalKey : null;
|
|
160
|
+
};
|
|
161
|
+
export const resolveGraphCollectionLocales = (graph, identity, collection) => {
|
|
162
|
+
const canonicalKey = resolveGraphCanonicalKey(graph, identity, collection);
|
|
163
|
+
if (!canonicalKey) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
return Object.values(graph.byCanonical[canonicalKey] || {}).sort((a, b) => a.locale.localeCompare(b.locale)).map((variant) => ({
|
|
167
|
+
canonicalKey,
|
|
168
|
+
locale: variant.locale,
|
|
169
|
+
...variant.path ? { path: variant.path } : {}
|
|
170
|
+
}));
|
|
171
|
+
};
|
|
172
|
+
export const selectGraphDocuments = (graph, options = {}) => {
|
|
173
|
+
const { collection, paths = [] } = options;
|
|
174
|
+
const hasIndexedFilter = Boolean(collection || paths.length);
|
|
175
|
+
let ids = collection ? [...graph.byCollection[collection] || []] : [];
|
|
176
|
+
if (paths.length) {
|
|
177
|
+
const pathIds = Array.from(new Set(paths.flatMap((path) => {
|
|
178
|
+
return Object.keys(graph.byPath).filter((key) => path instanceof RegExp ? path.test(key) : key === path).flatMap((key) => graph.byPath[key] || []);
|
|
179
|
+
})));
|
|
180
|
+
ids = ids.length ? pathIds.filter((id) => ids.includes(id)) : pathIds;
|
|
181
|
+
}
|
|
182
|
+
if (!ids.length) {
|
|
183
|
+
if (hasIndexedFilter) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
return graph.documents;
|
|
187
|
+
}
|
|
188
|
+
return ids.map((id) => graph.byId[id]).filter(Boolean);
|
|
189
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ignore.js'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function makeIgnored(ignores) {
|
|
2
|
+
const patterns = ["/\\.", "/-", ...ignores.filter(Boolean)].map((pattern) => new RegExp(pattern));
|
|
3
|
+
return function isIgnored(key) {
|
|
4
|
+
const path = `/${key.replace(/:/g, "/")}`;
|
|
5
|
+
if (path.endsWith("/.navigation.yml")) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return patterns.some((pattern) => pattern.test(path));
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './locale.js'
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale utilities shared by the graph, the query planner, and the ingest
|
|
3
|
+
* pipeline. Three concepts to keep straight:
|
|
4
|
+
*
|
|
5
|
+
* 1. **Fallback chain** — the ordered list of locales to try when a
|
|
6
|
+
* variant is missing (`buildLocaleFallbackChain`). User-configured
|
|
7
|
+
* per-locale fallbacks come first; the site default ties it off.
|
|
8
|
+
*
|
|
9
|
+
* 2. **Inline locale variant id** — YAML/JSON sources can carry locale
|
|
10
|
+
* overrides inline (`i18n: { de: { title: '…' } }`). We split each
|
|
11
|
+
* such document into one variant per locale at ingest; the
|
|
12
|
+
* synthetic variants share a `_id` shape of
|
|
13
|
+
* `${sourceId}#__locale=${locale}`. `splitInlineLocaleVariantId`
|
|
14
|
+
* reverses that for lookups.
|
|
15
|
+
*
|
|
16
|
+
* 3. **Inline override merge** — `expandDataLocaleVariants` does a
|
|
17
|
+
* deep merge of the base document with each locale-specific
|
|
18
|
+
* override, cloning values along the way so variants never share
|
|
19
|
+
* references with the base or with each other.
|
|
20
|
+
*/
|
|
21
|
+
import type { ParsedContent } from '../../types/content';
|
|
22
|
+
import type { ContentCollectionI18nConfig } from '../../types/config';
|
|
23
|
+
/** Separator between source id and locale in inline-variant ids. */
|
|
24
|
+
export declare const INLINE_LOCALE_ID_SEPARATOR = "#__locale=";
|
|
25
|
+
/**
|
|
26
|
+
* Produce the fallback chain for a specific locale (excluding the locale
|
|
27
|
+
* itself). The caller prepends the requested locale if it wants a
|
|
28
|
+
* walkable chain — this helper is what to look at *after* the requested
|
|
29
|
+
* locale missed.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* buildLocaleFallbackChain('fr', 'en', { fr: ['de'] }) // ['de', 'en']
|
|
33
|
+
* buildLocaleFallbackChain('en', 'en') // []
|
|
34
|
+
*/
|
|
35
|
+
export declare const buildLocaleFallbackChain: (locale: string, defaultLocale?: string, fallback?: Record<string, string[]>) => string[];
|
|
36
|
+
/**
|
|
37
|
+
* Split an inline-variant id back into `{ sourceId, locale }`. Returns the
|
|
38
|
+
* input unchanged (with `locale: undefined`) when no separator is found.
|
|
39
|
+
*/
|
|
40
|
+
export declare const splitInlineLocaleVariantId: (id: string) => {
|
|
41
|
+
sourceId: string;
|
|
42
|
+
locale: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Expand a single YAML/JSON document with inline `i18n` overrides into one
|
|
46
|
+
* document per configured locale.
|
|
47
|
+
*
|
|
48
|
+
* Markdown documents are returned unchanged — they express locale
|
|
49
|
+
* variants via filename (`index.en.md`, `index.de.md`) rather than
|
|
50
|
+
* inline keys, so the ingest pipeline already produces one document
|
|
51
|
+
* per variant.
|
|
52
|
+
*
|
|
53
|
+
* The base document (without the `i18n` key) becomes the source-locale
|
|
54
|
+
* variant. Each sibling locale gets a deep-merged variant that inherits
|
|
55
|
+
* from the base and overrides keys listed under `i18n[locale]`.
|
|
56
|
+
*
|
|
57
|
+
* GOTCHA: a non-object override (e.g. a string) is skipped with a warn.
|
|
58
|
+
* We do not throw — translation data is user-authored and one malformed
|
|
59
|
+
* override should not fail ingest for the whole document.
|
|
60
|
+
*/
|
|
61
|
+
export declare const expandDataLocaleVariants: (document: ParsedContent, i18nConfig?: ContentCollectionI18nConfig) => ParsedContent[];
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const INLINE_LOCALE_ID_SEPARATOR = "#__locale=";
|
|
2
|
+
const isPlainObject = (value) => {
|
|
3
|
+
return Boolean(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
4
|
+
};
|
|
5
|
+
const cloneValue = (value) => {
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return value.map((item) => cloneValue(item));
|
|
8
|
+
}
|
|
9
|
+
if (isPlainObject(value)) {
|
|
10
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneValue(item)]));
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
14
|
+
const mergeLocaleOverride = (base, override) => {
|
|
15
|
+
if (typeof override === "undefined") {
|
|
16
|
+
return cloneValue(base);
|
|
17
|
+
}
|
|
18
|
+
if (Array.isArray(override)) {
|
|
19
|
+
return cloneValue(override);
|
|
20
|
+
}
|
|
21
|
+
if (isPlainObject(base) && isPlainObject(override)) {
|
|
22
|
+
const merged = Object.fromEntries(Object.entries(base).map(([key, value]) => [key, cloneValue(value)]));
|
|
23
|
+
for (const [key, value] of Object.entries(override)) {
|
|
24
|
+
merged[key] = key in merged ? mergeLocaleOverride(merged[key], value) : cloneValue(value);
|
|
25
|
+
}
|
|
26
|
+
return merged;
|
|
27
|
+
}
|
|
28
|
+
return cloneValue(override);
|
|
29
|
+
};
|
|
30
|
+
export const buildLocaleFallbackChain = (locale, defaultLocale, fallback) => {
|
|
31
|
+
return Array.from(/* @__PURE__ */ new Set([
|
|
32
|
+
...fallback?.[locale] || [],
|
|
33
|
+
...defaultLocale && defaultLocale !== locale ? [defaultLocale] : []
|
|
34
|
+
]));
|
|
35
|
+
};
|
|
36
|
+
export const splitInlineLocaleVariantId = (id) => {
|
|
37
|
+
const separatorIndex = id.indexOf(INLINE_LOCALE_ID_SEPARATOR);
|
|
38
|
+
if (separatorIndex === -1) {
|
|
39
|
+
return { sourceId: id, locale: void 0 };
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
sourceId: id.slice(0, separatorIndex),
|
|
43
|
+
locale: id.slice(separatorIndex + INLINE_LOCALE_ID_SEPARATOR.length) || void 0
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const expandDataLocaleVariants = (document, i18nConfig) => {
|
|
47
|
+
if (!i18nConfig || document._type !== "yaml" && document._type !== "json") {
|
|
48
|
+
return [document];
|
|
49
|
+
}
|
|
50
|
+
const rawI18n = isPlainObject(document.i18n) ? document.i18n : void 0;
|
|
51
|
+
if (!rawI18n) {
|
|
52
|
+
return [document];
|
|
53
|
+
}
|
|
54
|
+
const { i18n: _removed, ...baseDocument } = document;
|
|
55
|
+
const sourceLocale = document._locale || i18nConfig.defaultLocale;
|
|
56
|
+
const variants = [{ ...baseDocument, _locale: sourceLocale }];
|
|
57
|
+
for (const locale of i18nConfig.locales) {
|
|
58
|
+
if (locale === sourceLocale) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const override = rawI18n[locale];
|
|
62
|
+
if (typeof override !== "undefined" && !isPlainObject(override)) {
|
|
63
|
+
console.warn(`[content] Inline i18n override for locale "${locale}" in "${document._id}" must be an object. Skipping invalid override.`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (!isPlainObject(override)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const merged = mergeLocaleOverride(baseDocument, override);
|
|
70
|
+
variants.push({
|
|
71
|
+
...merged,
|
|
72
|
+
_id: `${document._id}${INLINE_LOCALE_ID_SEPARATOR}${locale}`,
|
|
73
|
+
_locale: locale
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return variants;
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './path.js'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const describeId: (id: string) => {
|
|
2
|
+
_source: string;
|
|
3
|
+
_path: string;
|
|
4
|
+
_extension: string;
|
|
5
|
+
_file: string;
|
|
6
|
+
_basename: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const isDraftPath: (path: string) => boolean;
|
|
9
|
+
export declare const isPartialPath: (path: string) => boolean;
|
|
10
|
+
export declare const normalizeContentPath: (path: string) => string;
|
|
11
|
+
export declare function refineUrlPart(name: string): string;
|
|
12
|
+
export declare const generatePath: (path: string, { forceLeadingSlash, respectPathCase }?: {
|
|
13
|
+
forceLeadingSlash?: boolean;
|
|
14
|
+
respectPathCase?: boolean;
|
|
15
|
+
}) => string;
|
|
16
|
+
export declare const generateCanonicalKey: (parts: string[], { translatedSlugs, respectPathCase }?: {
|
|
17
|
+
translatedSlugs?: boolean;
|
|
18
|
+
respectPathCase?: boolean;
|
|
19
|
+
}) => string;
|
|
20
|
+
export declare const generateTitle: (path: string) => string;
|
|
21
|
+
export type RouteMounts = Record<string, string>;
|
|
22
|
+
export declare const normalizeRouteMounts: (route: string | Record<string, string> | undefined, locales?: string[], defaultLocale?: string) => RouteMounts | undefined;
|
|
23
|
+
export declare const longestMountForPath: (path: string, mounts: RouteMounts) => [string, string];
|
|
24
|
+
export declare const routeRemainder: (path: string, mount: string) => string;
|
|
25
|
+
export declare const mountContentPath: (remainder: string, locale: string | undefined, mounts?: RouteMounts) => string;
|
|
26
|
+
export declare const prefixPathWithLocale: (path: string, locale?: string, defaultLocale?: string) => string;
|
|
27
|
+
export declare const stripLocalePrefix: (path: string, locales?: string[], defaultLocale?: string, explicitLocale?: string) => {
|
|
28
|
+
locale: string | undefined;
|
|
29
|
+
path: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const routeToContentPathCandidates: (route: string, requestedLocale: string | undefined, localeChain: string[], defaultLocale?: string, mounts?: RouteMounts) => {
|
|
32
|
+
locale: string;
|
|
33
|
+
path: string;
|
|
34
|
+
}[];
|
|
35
|
+
export declare const projectContentPathToLocale: (path: string, locale?: string, defaultLocale?: string, mounts?: RouteMounts) => string;
|
|
36
|
+
export declare const pathHasLocalePrefix: (path: string, locales: string[]) => boolean;
|