@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,21 @@
|
|
|
1
|
+
import type { ParsedContent } from '../../types/content';
|
|
2
|
+
import type { ContentCollectionSearchSectionsOptions, ContentSearchSection } from '../../types/query';
|
|
3
|
+
type SearchablePage = Pick<ParsedContent, '_path' | 'title' | 'description' | 'body'> & Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* Backing option type for search-section generation.
|
|
6
|
+
*
|
|
7
|
+
* Re-exported through the public query surface as
|
|
8
|
+
* `ContentCollectionSearchSectionsOptions`.
|
|
9
|
+
*/
|
|
10
|
+
export type GenerateSearchSectionsOptions = ContentCollectionSearchSectionsOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Searchable content section emitted for one page heading range.
|
|
13
|
+
*
|
|
14
|
+
* Re-exported through the public query surface as `ContentSearchSection`.
|
|
15
|
+
*/
|
|
16
|
+
export type SearchSection = ContentSearchSection;
|
|
17
|
+
/**
|
|
18
|
+
* Split pages into searchable sections for pagefind-like indexing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function createSearchSections(pages: SearchablePage[], opts?: GenerateSearchSectionsOptions): SearchSection[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const HEADING = /^h([1-6])$/;
|
|
2
|
+
const headingLevel = (tag) => Number(tag.match(HEADING)?.[1] ?? 0);
|
|
3
|
+
export function createSearchSections(pages, opts) {
|
|
4
|
+
const { ignoredTags = ["pre", "style", "script"], extraFields = [], minHeading = "h1", maxHeading = "h6" } = opts || {};
|
|
5
|
+
const minLevel = headingLevel(minHeading);
|
|
6
|
+
const maxLevel = headingLevel(maxHeading);
|
|
7
|
+
return pages.flatMap(
|
|
8
|
+
(page) => splitPageIntoSections(page, {
|
|
9
|
+
ignoredTags,
|
|
10
|
+
extraFields,
|
|
11
|
+
minLevel,
|
|
12
|
+
maxLevel
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function splitPageIntoSections(page, {
|
|
17
|
+
ignoredTags,
|
|
18
|
+
extraFields,
|
|
19
|
+
minLevel,
|
|
20
|
+
maxLevel
|
|
21
|
+
}) {
|
|
22
|
+
const path = page._path || "";
|
|
23
|
+
const extraFieldsData = pick(extraFields, page);
|
|
24
|
+
const body = page.body;
|
|
25
|
+
const sections = [{
|
|
26
|
+
...extraFieldsData,
|
|
27
|
+
id: path,
|
|
28
|
+
title: normalizeSearchText(String(page.title || "")),
|
|
29
|
+
titles: [],
|
|
30
|
+
content: normalizeSearchText(String(page.description || "")),
|
|
31
|
+
level: 1
|
|
32
|
+
}];
|
|
33
|
+
if (!body?.children) {
|
|
34
|
+
return sections;
|
|
35
|
+
}
|
|
36
|
+
let section = 1;
|
|
37
|
+
let previousHeadingLevel = 0;
|
|
38
|
+
const titles = [normalizeSearchText(String(page.title || ""))];
|
|
39
|
+
for (const item of body.children) {
|
|
40
|
+
const tag = item.tag || "";
|
|
41
|
+
const level = headingLevel(tag);
|
|
42
|
+
if (level >= minLevel && level <= maxLevel) {
|
|
43
|
+
const title = extractTextFromAst(item).trim();
|
|
44
|
+
if (level === 1) {
|
|
45
|
+
titles.splice(0, titles.length);
|
|
46
|
+
} else if (level < previousHeadingLevel) {
|
|
47
|
+
titles.splice(level - 1, titles.length - 1);
|
|
48
|
+
} else if (level === previousHeadingLevel) {
|
|
49
|
+
titles.pop();
|
|
50
|
+
}
|
|
51
|
+
sections.push({
|
|
52
|
+
...extraFieldsData,
|
|
53
|
+
id: `${path}#${item.props?.id || ""}`,
|
|
54
|
+
title,
|
|
55
|
+
titles: [...titles],
|
|
56
|
+
content: "",
|
|
57
|
+
level
|
|
58
|
+
});
|
|
59
|
+
titles.push(title);
|
|
60
|
+
previousHeadingLevel = level;
|
|
61
|
+
section += 1;
|
|
62
|
+
} else {
|
|
63
|
+
const content = normalizeSearchText(extractTextFromAst(item, ignoredTags));
|
|
64
|
+
if (section === 1 && sections[section - 1]?.content === content) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
sections[section - 1].content = `${sections[section - 1].content} ${content}`.trim();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return sections;
|
|
71
|
+
}
|
|
72
|
+
function extractTextFromAst(node, ignoredTags = []) {
|
|
73
|
+
let text = "";
|
|
74
|
+
if (node.type === "text") {
|
|
75
|
+
text += node.value || "";
|
|
76
|
+
}
|
|
77
|
+
if (ignoredTags.includes(node.tag || "")) {
|
|
78
|
+
return "";
|
|
79
|
+
}
|
|
80
|
+
if (node.children?.length) {
|
|
81
|
+
text += node.children.map((child) => extractTextFromAst(child, ignoredTags)).filter(Boolean).join("");
|
|
82
|
+
}
|
|
83
|
+
return text;
|
|
84
|
+
}
|
|
85
|
+
function normalizeSearchText(value) {
|
|
86
|
+
return value.replace(/\[([^\]]+)\x5D\x7B[^\x7D]+\x7D/g, "$1").replace(/\s+/g, " ").trim();
|
|
87
|
+
}
|
|
88
|
+
function pick(fields, page) {
|
|
89
|
+
if (!fields.length) {
|
|
90
|
+
return {};
|
|
91
|
+
}
|
|
92
|
+
return fields.reduce((result, field) => {
|
|
93
|
+
if (typeof page[field] !== "undefined") {
|
|
94
|
+
result[field] = page[field];
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}, {});
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query.js'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ContentSitemapEntry } from '../../types/query';
|
|
2
|
+
type ContentLikePage = {
|
|
3
|
+
_path?: string;
|
|
4
|
+
_collection?: string;
|
|
5
|
+
_canonicalKey?: string;
|
|
6
|
+
_locale?: string;
|
|
7
|
+
_draft?: boolean;
|
|
8
|
+
sitemap?: unknown;
|
|
9
|
+
body?: unknown;
|
|
10
|
+
image?: unknown;
|
|
11
|
+
seo?: unknown;
|
|
12
|
+
ogImage?: unknown;
|
|
13
|
+
};
|
|
14
|
+
type LocaleConfig = {
|
|
15
|
+
code: string;
|
|
16
|
+
language?: string;
|
|
17
|
+
};
|
|
18
|
+
export interface QueryCollectionsSitemapEntriesOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Restrict generation to these collection names.
|
|
21
|
+
*/
|
|
22
|
+
include?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Exclude these collection names from generation.
|
|
25
|
+
*/
|
|
26
|
+
exclude?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Include draft entries. Defaults to `true` in dev and `false` otherwise.
|
|
29
|
+
*/
|
|
30
|
+
includeDrafts?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Absolute site URL used to expand relative paths in the final entries.
|
|
33
|
+
*/
|
|
34
|
+
siteUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface SitemapRuntime {
|
|
37
|
+
collections?: Record<string, {
|
|
38
|
+
sitemap?: boolean;
|
|
39
|
+
} | unknown>;
|
|
40
|
+
defaultLocale?: string;
|
|
41
|
+
runtimeSiteUrl?: string;
|
|
42
|
+
localeConfigs?: LocaleConfig[];
|
|
43
|
+
requestSiteUrl?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface SitemapLoaders {
|
|
46
|
+
loadCollectionPages: (collection: string) => Promise<ContentLikePage[]>;
|
|
47
|
+
loadRouteMeta: (collection: string, path: string, locale?: string) => Promise<{
|
|
48
|
+
locale: string;
|
|
49
|
+
path: string;
|
|
50
|
+
defaultLocale: string;
|
|
51
|
+
variants: Array<{
|
|
52
|
+
locale: string;
|
|
53
|
+
path: string;
|
|
54
|
+
}>;
|
|
55
|
+
} | null>;
|
|
56
|
+
loadPage: (collection: string, path: string, locale?: string) => Promise<{
|
|
57
|
+
body?: unknown;
|
|
58
|
+
} | null>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build sitemap entries from collection pages plus route/page loaders.
|
|
62
|
+
*
|
|
63
|
+
* This is the pure implementation behind the public server helper. It keeps
|
|
64
|
+
* URL resolution, locale alternatives, and image extraction testable without
|
|
65
|
+
* coupling the logic to Nitro.
|
|
66
|
+
*/
|
|
67
|
+
export declare function queryCollectionsSitemapEntriesData(runtime: SitemapRuntime, loaders: SitemapLoaders, options?: QueryCollectionsSitemapEntriesOptions): Promise<ContentSitemapEntry[]>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { createContentProviderError } from "../../public/provider-errors";
|
|
2
|
+
const normalizeSiteUrl = (siteUrl) => siteUrl?.replace(/\/$/, "");
|
|
3
|
+
const resolveSiteUrl = (runtime, explicitSiteUrl) => {
|
|
4
|
+
const normalizedExplicitSiteUrl = normalizeSiteUrl(explicitSiteUrl);
|
|
5
|
+
if (normalizedExplicitSiteUrl) {
|
|
6
|
+
return normalizedExplicitSiteUrl;
|
|
7
|
+
}
|
|
8
|
+
const normalizedRuntimeSiteUrl = normalizeSiteUrl(runtime.runtimeSiteUrl);
|
|
9
|
+
if (normalizedRuntimeSiteUrl) {
|
|
10
|
+
return normalizedRuntimeSiteUrl;
|
|
11
|
+
}
|
|
12
|
+
if (runtime.requestSiteUrl && process.env.NODE_ENV !== "production") {
|
|
13
|
+
return runtime.requestSiteUrl;
|
|
14
|
+
}
|
|
15
|
+
if (process.env.NODE_ENV === "production") {
|
|
16
|
+
throw new Error("Content sitemap generation requires site.url or runtimeConfig.public.siteUrl in production.");
|
|
17
|
+
}
|
|
18
|
+
return "http://localhost";
|
|
19
|
+
};
|
|
20
|
+
const collectContentImageUrls = (body, urls = /* @__PURE__ */ new Set()) => {
|
|
21
|
+
if (!body) {
|
|
22
|
+
return urls;
|
|
23
|
+
}
|
|
24
|
+
if (typeof body !== "object") {
|
|
25
|
+
return urls;
|
|
26
|
+
}
|
|
27
|
+
const node = body;
|
|
28
|
+
if (node.tag === "img" && typeof node.props?.src === "string") {
|
|
29
|
+
urls.add(node.props.src);
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(node.children)) {
|
|
32
|
+
for (const child of node.children) {
|
|
33
|
+
collectContentImageUrls(child, urls);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (node.value) {
|
|
37
|
+
collectContentImageUrls(node.value, urls);
|
|
38
|
+
}
|
|
39
|
+
return urls;
|
|
40
|
+
};
|
|
41
|
+
const collectStructuredImageUrls = (value, urls = /* @__PURE__ */ new Set()) => {
|
|
42
|
+
if (!value || typeof value !== "object") {
|
|
43
|
+
return urls;
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
for (const item of value) {
|
|
47
|
+
collectStructuredImageUrls(item, urls);
|
|
48
|
+
}
|
|
49
|
+
return urls;
|
|
50
|
+
}
|
|
51
|
+
const record = value;
|
|
52
|
+
for (const key of ["src", "url", "loc"]) {
|
|
53
|
+
if (typeof record[key] === "string") {
|
|
54
|
+
urls.add(record[key]);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const nested of Object.values(record)) {
|
|
58
|
+
if (nested && typeof nested === "object") {
|
|
59
|
+
collectStructuredImageUrls(nested, urls);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return urls;
|
|
63
|
+
};
|
|
64
|
+
const toAbsoluteImageUrl = (siteUrl, loc) => {
|
|
65
|
+
try {
|
|
66
|
+
return new URL(loc).href;
|
|
67
|
+
} catch {
|
|
68
|
+
return loc.startsWith("/") ? `${siteUrl}${loc}` : loc;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const toPageSitemapImages = (siteUrl, page, body) => {
|
|
72
|
+
const urls = collectContentImageUrls(body);
|
|
73
|
+
if (page) {
|
|
74
|
+
collectStructuredImageUrls(page.sitemap, urls);
|
|
75
|
+
collectStructuredImageUrls(page.image, urls);
|
|
76
|
+
collectStructuredImageUrls(page.seo, urls);
|
|
77
|
+
collectStructuredImageUrls(page.ogImage, urls);
|
|
78
|
+
}
|
|
79
|
+
const images = Array.from(urls).map((loc) => ({ loc: toAbsoluteImageUrl(siteUrl, loc) }));
|
|
80
|
+
return images.length ? images : void 0;
|
|
81
|
+
};
|
|
82
|
+
const toAbsoluteUrl = (siteUrl, path) => `${siteUrl}${path}`;
|
|
83
|
+
const buildAlternatives = (siteUrl, defaultLocale, localeToLanguage, variants) => {
|
|
84
|
+
const alternatives = variants.map((variant) => ({
|
|
85
|
+
hreflang: localeToLanguage[variant.locale] || variant.locale,
|
|
86
|
+
href: toAbsoluteUrl(siteUrl, variant.path)
|
|
87
|
+
}));
|
|
88
|
+
const defaultVariant = variants.find((variant) => variant.locale === defaultLocale);
|
|
89
|
+
if (defaultVariant) {
|
|
90
|
+
alternatives.unshift({
|
|
91
|
+
hreflang: "x-default",
|
|
92
|
+
href: toAbsoluteUrl(siteUrl, defaultVariant.path)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return alternatives;
|
|
96
|
+
};
|
|
97
|
+
const resolveSitemapCollections = (runtime, options = {}) => {
|
|
98
|
+
const hasExplicitInclude = Boolean(options.include?.length);
|
|
99
|
+
const include = hasExplicitInclude ? options.include : Object.keys(runtime.collections || {});
|
|
100
|
+
const excluded = new Set(options.exclude || []);
|
|
101
|
+
return include.filter((collection) => {
|
|
102
|
+
const config = runtime.collections?.[collection];
|
|
103
|
+
if (excluded.has(collection)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (config?.sitemap === false) {
|
|
107
|
+
if (hasExplicitInclude) {
|
|
108
|
+
throw createContentProviderError("data_collection_sitemap_access", `${collection} is not sitemap-backed.`, {
|
|
109
|
+
collection
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
export async function queryCollectionsSitemapEntriesData(runtime, loaders, options = {}) {
|
|
118
|
+
const localeToLanguage = Object.fromEntries((runtime.localeConfigs || []).map((locale) => [locale.code, locale.language || locale.code]));
|
|
119
|
+
const collections = resolveSitemapCollections(runtime, options);
|
|
120
|
+
const siteUrl = resolveSiteUrl(runtime, options.siteUrl);
|
|
121
|
+
const shouldIncludeDrafts = typeof options.includeDrafts === "boolean" ? options.includeDrafts : import.meta.dev;
|
|
122
|
+
const pages = (await Promise.all(collections.map(async (collection) => {
|
|
123
|
+
const collectionPages = await loaders.loadCollectionPages(collection);
|
|
124
|
+
return collectionPages.map((page) => ({
|
|
125
|
+
...page,
|
|
126
|
+
_collection: page._collection || collection
|
|
127
|
+
}));
|
|
128
|
+
}))).flat().filter((page) => {
|
|
129
|
+
if (page.sitemap === false) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return shouldIncludeDrafts || !page._draft;
|
|
133
|
+
});
|
|
134
|
+
const uniquePages = Array.from(new Map(
|
|
135
|
+
pages.map((page) => [
|
|
136
|
+
`${page._collection || ""}:${page._canonicalKey || page._path || ""}`,
|
|
137
|
+
page
|
|
138
|
+
])
|
|
139
|
+
).values());
|
|
140
|
+
const rawEntries = await Promise.all(uniquePages.map(async (page) => {
|
|
141
|
+
if (!page._path || !page._collection) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
const meta = await loaders.loadRouteMeta(page._collection, page._path, page._locale);
|
|
145
|
+
if (!meta) {
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
const variants = (meta.variants.length ? meta.variants : [{ locale: meta.locale, path: meta.path }]).filter((variant) => variant.path);
|
|
149
|
+
const localizedVariants = variants.filter((variant) => variant.locale);
|
|
150
|
+
const alternatives = localizedVariants.length > 1 ? buildAlternatives(siteUrl, meta.defaultLocale, localeToLanguage, variants) : void 0;
|
|
151
|
+
return await Promise.all(variants.map(async (variant) => {
|
|
152
|
+
const variantPage = await loaders.loadPage(page._collection, variant.path, variant.locale);
|
|
153
|
+
const images = toPageSitemapImages(
|
|
154
|
+
siteUrl,
|
|
155
|
+
variantPage ? { ...page, ...variantPage } : page,
|
|
156
|
+
variantPage?.body ?? page.body
|
|
157
|
+
);
|
|
158
|
+
return {
|
|
159
|
+
loc: variant.path,
|
|
160
|
+
...variant.locale ? { _sitemap: localeToLanguage[variant.locale] || variant.locale } : {},
|
|
161
|
+
...alternatives ? { alternatives } : {},
|
|
162
|
+
...images ? { images } : {}
|
|
163
|
+
};
|
|
164
|
+
}));
|
|
165
|
+
}));
|
|
166
|
+
const uniqueEntries = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const entry of rawEntries.flat()) {
|
|
168
|
+
uniqueEntries.set(`${entry._sitemap || "default"}:${entry.loc}`, entry);
|
|
169
|
+
}
|
|
170
|
+
return Array.from(uniqueEntries.values());
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './context.js'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nitro request-scoped runtime context.
|
|
3
|
+
*
|
|
4
|
+
* This file defines the single place where mutable, request-scoped state lives.
|
|
5
|
+
* The hard rule is:
|
|
6
|
+
*
|
|
7
|
+
* Anything request-scoped lives on `ContentRuntimeContext`.
|
|
8
|
+
* Nowhere else. Not in module-level `let`s, not in cached imports.
|
|
9
|
+
*
|
|
10
|
+
* Why: Nitro reuses the process across requests. Module-level `let` leaks one
|
|
11
|
+
* request's parsed content, graph, or in-flight promises into another — a
|
|
12
|
+
* silent correctness bug that's near-impossible to reproduce locally.
|
|
13
|
+
*
|
|
14
|
+
* The context is attached to `event.context.__contentRuntime` and created
|
|
15
|
+
* lazily on first access. Memoization uses `memoizeRuntimeValue` so the
|
|
16
|
+
* `graph` / `contents` caches are shared across helpers within a single
|
|
17
|
+
* request but torn down with the event.
|
|
18
|
+
*/
|
|
19
|
+
import type { H3Event } from 'h3';
|
|
20
|
+
import type { Storage } from 'unstorage';
|
|
21
|
+
import type { ParsedContent } from '../../types/content';
|
|
22
|
+
import type { ContentContext as RuntimeContentConfig } from '../../types/module';
|
|
23
|
+
import type { ContentGraph } from '../../core/content/graph';
|
|
24
|
+
import type { ContentCacheStore } from '../../core/cache';
|
|
25
|
+
import type { ContentCacheHint } from '../../public/provider';
|
|
26
|
+
/**
|
|
27
|
+
* Per-request runtime state. Everything request-scoped belongs here; nothing
|
|
28
|
+
* request-scoped belongs in module-level singletons.
|
|
29
|
+
*
|
|
30
|
+
* `caches` holds the request-local parsed-content store and single-flight maps.
|
|
31
|
+
* It is populated lazily on first access by
|
|
32
|
+
* `storage/cache.ts#cacheStoreFor()` so this module does not have to reach into
|
|
33
|
+
* the `storage` layer at construction time (that would break the allowed
|
|
34
|
+
* dependency direction `integrations/ → storage/`, never the reverse).
|
|
35
|
+
*/
|
|
36
|
+
export interface ContentRuntimeContext {
|
|
37
|
+
config: RuntimeContentConfig;
|
|
38
|
+
now: () => Date;
|
|
39
|
+
storages?: {
|
|
40
|
+
sourceStorage: Storage;
|
|
41
|
+
cacheStorage: Storage;
|
|
42
|
+
cacheParsedStorage: Storage;
|
|
43
|
+
};
|
|
44
|
+
memo: {
|
|
45
|
+
contents?: ParsedContent[] | Promise<ParsedContent[]>;
|
|
46
|
+
graph?: ContentGraph | Promise<ContentGraph>;
|
|
47
|
+
};
|
|
48
|
+
caches?: ContentCacheStore<ParsedContent>;
|
|
49
|
+
cacheHint?: ContentCacheHint | false;
|
|
50
|
+
}
|
|
51
|
+
export declare const getContentRuntimeContext: (event: H3Event) => ContentRuntimeContext;
|
|
52
|
+
/**
|
|
53
|
+
* Memoize an expensive per-request value (typically `contents` or `graph`).
|
|
54
|
+
*
|
|
55
|
+
* Concurrent callers within a single request that hit the same key all await
|
|
56
|
+
* the one `create()` promise — we do not start a second compute. The cache
|
|
57
|
+
* lives on `runtime.memo` so it is freed when the event is garbage-collected.
|
|
58
|
+
*
|
|
59
|
+
* GOTCHA: `create` runs only on miss. If you need a fresh value mid-request,
|
|
60
|
+
* you cannot use this helper — mutate `runtime.memo[key]` directly. In
|
|
61
|
+
* practice, nothing we build mid-request invalidates the graph.
|
|
62
|
+
*/
|
|
63
|
+
export declare const memoizeRuntimeValue: <T>(event: H3Event, key: keyof ContentRuntimeContext["memo"], create: () => Promise<T>) => Promise<T>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getContentRuntimeConfig } from "./runtime-config.js";
|
|
2
|
+
const createRuntimeContext = () => ({
|
|
3
|
+
config: getContentRuntimeConfig().content,
|
|
4
|
+
now: () => /* @__PURE__ */ new Date(),
|
|
5
|
+
memo: {}
|
|
6
|
+
});
|
|
7
|
+
export const getContentRuntimeContext = (event) => {
|
|
8
|
+
const context = event.context ||= {};
|
|
9
|
+
context.__contentRuntime ||= createRuntimeContext();
|
|
10
|
+
return context.__contentRuntime;
|
|
11
|
+
};
|
|
12
|
+
export const memoizeRuntimeValue = async (event, key, create) => {
|
|
13
|
+
const runtime = getContentRuntimeContext(event);
|
|
14
|
+
const cached = runtime.memo[key];
|
|
15
|
+
if (typeof cached !== "undefined") {
|
|
16
|
+
return cached;
|
|
17
|
+
}
|
|
18
|
+
const pending = create();
|
|
19
|
+
runtime.memo[key] = pending;
|
|
20
|
+
try {
|
|
21
|
+
const value = await pending;
|
|
22
|
+
runtime.memo[key] = value;
|
|
23
|
+
return value;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
runtime.memo[key] = void 0;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ingest.js'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StorageValue } from 'unstorage';
|
|
2
|
+
import type { ParsedContent } from '../../types/content';
|
|
3
|
+
import type { ParseContentOptions } from '../../types/runtime';
|
|
4
|
+
import type { ContentContext } from '../../types/module';
|
|
5
|
+
/**
|
|
6
|
+
* Ingest a single source file into an array of `ParsedContent` variants
|
|
7
|
+
* (one per locale, including the default).
|
|
8
|
+
*
|
|
9
|
+
* The returned array is the full variant fan-out. Callers that want a
|
|
10
|
+
* specific locale select from it; callers that want the canonical document
|
|
11
|
+
* take `[0]` (see `parseContent` below).
|
|
12
|
+
*
|
|
13
|
+
* Throws a typed `ContentError` on failure — parse errors, transform errors,
|
|
14
|
+
* schema violations, and collection-path ambiguity all surface as specific
|
|
15
|
+
* `ContentErrorCode`s so HTTP and build-time callers can branch on them.
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseContentVariants: (id: string, content: StorageValue, runtimeContentConfig: ContentContext, opts?: ParseContentOptions) => Promise<ParsedContent[]>;
|
|
18
|
+
export declare const parseContent: (id: string, content: StorageValue, runtimeContentConfig: ContentContext, opts?: ParseContentOptions) => Promise<ParsedContent>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import defu from "defu";
|
|
2
|
+
import { useNitroApp } from "nitropack/runtime";
|
|
3
|
+
import { ContentError } from "../../core/errors";
|
|
4
|
+
import { transformContent } from "../../parsers";
|
|
5
|
+
import { resolveCollection, resolveCollections } from "../../core/content/collection";
|
|
6
|
+
import { expandDataLocaleVariants } from "../../core/content/locale";
|
|
7
|
+
import { createContentError, validateCollectionDocument } from "../../storage/validation";
|
|
8
|
+
const loadCustomTransformers = async () => {
|
|
9
|
+
try {
|
|
10
|
+
const specifier = "#content/virtual/transformers";
|
|
11
|
+
const module = await import(
|
|
12
|
+
/* @vite-ignore */
|
|
13
|
+
specifier
|
|
14
|
+
);
|
|
15
|
+
return module.transformers || [];
|
|
16
|
+
} catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const invalidContentError = (id, cause) => new ContentError("INVALID_CONTENT", `Failed to ingest content "${id}"`, { id }, { cause });
|
|
21
|
+
const parseSource = async (id, body, options) => {
|
|
22
|
+
try {
|
|
23
|
+
return await transformContent(id, body, {
|
|
24
|
+
...options,
|
|
25
|
+
pathMeta: {
|
|
26
|
+
...options.pathMeta,
|
|
27
|
+
collectionResolver: (filePath) => resolveCollection(filePath, options.pathMeta?.collections, options.pathMeta?.locales || [])
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
} catch (cause) {
|
|
31
|
+
throw new ContentError(
|
|
32
|
+
"PARSE_FAILED",
|
|
33
|
+
`Failed to parse content "${id}"`,
|
|
34
|
+
{ id },
|
|
35
|
+
{ cause }
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const expandLocaleVariants = async (document, options) => {
|
|
40
|
+
try {
|
|
41
|
+
const collection = document._collection && options.pathMeta?.collections ? options.pathMeta.collections[document._collection] : void 0;
|
|
42
|
+
return expandDataLocaleVariants(document, collection?.i18n);
|
|
43
|
+
} catch (cause) {
|
|
44
|
+
throw new ContentError(
|
|
45
|
+
"TRANSFORM_FAILED",
|
|
46
|
+
`Failed to transform content "${document._file || document._id}"`,
|
|
47
|
+
{ id: document._id, file: document._file },
|
|
48
|
+
{ cause }
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const validateVariants = (id, variants, options) => {
|
|
53
|
+
if (options.validate === false) {
|
|
54
|
+
return variants;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return variants.map((variant) => {
|
|
58
|
+
const outcome = validateCollectionDocument(variant, options.pathMeta?.collections);
|
|
59
|
+
if (!outcome.ok) {
|
|
60
|
+
throw outcome.error;
|
|
61
|
+
}
|
|
62
|
+
return outcome.value;
|
|
63
|
+
});
|
|
64
|
+
} catch (cause) {
|
|
65
|
+
if (cause instanceof ContentError) {
|
|
66
|
+
throw cause;
|
|
67
|
+
}
|
|
68
|
+
throw invalidContentError(id, new ContentError(
|
|
69
|
+
"VALIDATION_FAILED",
|
|
70
|
+
"Failed to validate parsed content",
|
|
71
|
+
{
|
|
72
|
+
files: variants.map((document) => document._file || document._id)
|
|
73
|
+
},
|
|
74
|
+
{ cause }
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const parseContentVariants = async (id, content, runtimeContentConfig, opts = {}) => {
|
|
79
|
+
const nitroApp = useNitroApp();
|
|
80
|
+
const customTransformers = await loadCustomTransformers();
|
|
81
|
+
const options = defu(
|
|
82
|
+
opts,
|
|
83
|
+
{
|
|
84
|
+
markdown: runtimeContentConfig.markdown,
|
|
85
|
+
csv: runtimeContentConfig.csv,
|
|
86
|
+
yaml: runtimeContentConfig.yaml,
|
|
87
|
+
transformers: customTransformers,
|
|
88
|
+
pathMeta: {
|
|
89
|
+
defaultLocale: runtimeContentConfig.defaultLocale,
|
|
90
|
+
translatedSlugs: runtimeContentConfig.translatedSlugs,
|
|
91
|
+
locales: runtimeContentConfig.locales,
|
|
92
|
+
respectPathCase: runtimeContentConfig.respectPathCase,
|
|
93
|
+
collections: runtimeContentConfig.collections
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
const file = { _id: id, body: typeof content === "string" ? content.replace(/\r\n|\r/g, "\n") : content };
|
|
98
|
+
await nitroApp.hooks.callHook("content:file:beforeParse", file);
|
|
99
|
+
const parsedDocument = await parseSource(id, file.body, options);
|
|
100
|
+
const variants = validateVariants(id, await expandLocaleVariants(parsedDocument, options), options);
|
|
101
|
+
const parsed = variants[0];
|
|
102
|
+
const matchedCollections = resolveCollections(parsed?._file || id, options.pathMeta?.collections, options.pathMeta?.locales || []);
|
|
103
|
+
if (matchedCollections.length > 1) {
|
|
104
|
+
throw createContentError(
|
|
105
|
+
"CONFLICTING_COLLECTION_MATCH",
|
|
106
|
+
parsed?._file || id,
|
|
107
|
+
"conflicting collection matches",
|
|
108
|
+
matchedCollections.join(", "),
|
|
109
|
+
{ collections: matchedCollections }
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (parsed) {
|
|
113
|
+
await nitroApp.hooks.callHook("content:file:afterParse", parsed);
|
|
114
|
+
}
|
|
115
|
+
return variants;
|
|
116
|
+
};
|
|
117
|
+
export const parseContent = async (id, content, runtimeContentConfig, opts = {}) => {
|
|
118
|
+
const variants = await parseContentVariants(id, content, runtimeContentConfig, opts);
|
|
119
|
+
return variants[0];
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './preview.js'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getCookie, getHeader, getQuery } from "h3";
|
|
2
|
+
import { getContentRuntimeConfig } from "./runtime-config.js";
|
|
3
|
+
const getIncomingPreviewToken = (event) => {
|
|
4
|
+
const queryToken = getQuery(event).previewToken;
|
|
5
|
+
if (typeof queryToken === "string") {
|
|
6
|
+
return queryToken;
|
|
7
|
+
}
|
|
8
|
+
return getHeader(event, "x-nuxt-content-preview") || getCookie(event, "previewToken");
|
|
9
|
+
};
|
|
10
|
+
const getConfiguredPreviewToken = () => {
|
|
11
|
+
const preview = getContentRuntimeConfig().content?.preview;
|
|
12
|
+
return preview && preview !== false && typeof preview.token === "string" && preview.token.length ? preview.token : void 0;
|
|
13
|
+
};
|
|
14
|
+
export const isPreview = (event) => {
|
|
15
|
+
const configuredToken = getConfiguredPreviewToken();
|
|
16
|
+
return Boolean(configuredToken && getIncomingPreviewToken(event) === configuredToken);
|
|
17
|
+
};
|
|
18
|
+
export const getPreview = (event) => {
|
|
19
|
+
const key = isPreview(event) ? getIncomingPreviewToken(event) : "";
|
|
20
|
+
return { key };
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime-config.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getContentRuntimeConfig(): import("nitropack/types").NitroRuntimeConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './storage.js'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Storage } from 'unstorage';
|
|
2
|
+
import type { H3Event } from 'h3';
|
|
3
|
+
export declare const sourceStorage: (event?: H3Event) => Storage<import("unstorage").StorageValue>;
|
|
4
|
+
export declare const cacheStorage: (event?: H3Event) => Storage<import("unstorage").StorageValue>;
|
|
5
|
+
export declare const cacheParsedStorage: (event?: H3Event) => Storage<import("unstorage").StorageValue>;
|
|
6
|
+
export declare const contentConfig: () => any;
|
|
7
|
+
export declare const contentIgnorePredicate: (key: string) => boolean;
|
|
8
|
+
export declare const getContentsIds: (event: H3Event, prefix?: string) => Promise<string[]>;
|
|
9
|
+
export declare const resolveStorageId: (event: H3Event, id: string) => Promise<string>;
|