@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 @@
|
|
|
1
|
+
export * from './index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { transformContent, defineTransformer } from '../../parsers/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { transformContent, defineTransformer } from "../../parsers/index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './json.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../parsers/json';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "../../parsers/json";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './markdown.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../parsers/markdown';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "../../parsers/markdown";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './path-meta.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineTransformer } from '../../parsers/utils';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineTransformer } from "../../parsers/utils";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './yaml.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../parsers/yaml';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "../../parsers/yaml";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content-components.js'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AsyncComponentLoader } from 'vue';
|
|
2
|
+
declare module '#build/content-components' {
|
|
3
|
+
const globalComponents: string[];
|
|
4
|
+
const localComponents: string[];
|
|
5
|
+
const localComponentLoaders: Record<string, AsyncComponentLoader>;
|
|
6
|
+
}
|
|
7
|
+
export declare const globalComponents: string[];
|
|
8
|
+
export declare const localComponents: string[];
|
|
9
|
+
export declare const localComponentLoaders: Record<string, AsyncComponentLoader>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const fallbackContentComponents = {
|
|
2
|
+
globalComponents: [],
|
|
3
|
+
localComponents: [],
|
|
4
|
+
localComponentLoaders: {}
|
|
5
|
+
};
|
|
6
|
+
async function loadContentComponents() {
|
|
7
|
+
try {
|
|
8
|
+
return await import("#build/content-components");
|
|
9
|
+
} catch {
|
|
10
|
+
return fallbackContentComponents;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const contentComponents = await loadContentComponents();
|
|
14
|
+
export const globalComponents = contentComponents.globalComponents;
|
|
15
|
+
export const localComponents = contentComponents.localComponents;
|
|
16
|
+
export const localComponentLoaders = contentComponents.localComponentLoaders;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query.js'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type H3Event } from 'h3';
|
|
2
|
+
import type { ContentQueryBuilderParams } from '../../types/query';
|
|
3
|
+
import { decodeQueryParams, encodeQueryParams, ensureQueryWhereArray, findQueryWhere, collectQueryWhere, normalizeContentQueryParams } from '../../core/query/params';
|
|
4
|
+
export declare const getContentQuery: (event: H3Event) => ContentQueryBuilderParams;
|
|
5
|
+
export { collectQueryWhere, decodeQueryParams, encodeQueryParams, ensureQueryWhereArray, findQueryWhere, normalizeContentQueryParams };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createError } from "h3";
|
|
2
|
+
import { decodeQueryParams, encodeQueryParams, ensureQueryWhereArray, findQueryWhere, collectQueryWhere, normalizeContentQueryParams } from "../../core/query/params";
|
|
3
|
+
const safeDecodeQueryParams = (encoded) => {
|
|
4
|
+
try {
|
|
5
|
+
return decodeQueryParams(encoded);
|
|
6
|
+
} catch {
|
|
7
|
+
throw createError({ statusCode: 400, message: "Invalid _params query" });
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const getContentQuery = (event) => {
|
|
11
|
+
const encoded = event.context.params?.params;
|
|
12
|
+
if (!encoded) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const normalized = encoded.replace(/\.json$/, "").replace(/^[^/]+\//, "");
|
|
16
|
+
return safeDecodeQueryParams(normalized);
|
|
17
|
+
};
|
|
18
|
+
export { collectQueryWhere, decodeQueryParams, encodeQueryParams, ensureQueryWhereArray, findQueryWhere, normalizeContentQueryParams };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare module '#build/content-i18n.mjs' {
|
|
2
|
+
export function useRouteBaseName(): (route: { name?: unknown } | unknown) => string | undefined
|
|
3
|
+
export function useSetI18nParams(): (params: Record<string, unknown>) => void
|
|
4
|
+
export function useSwitchLocalePath(): (locale: string) => string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './cache.js'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { ParsedContent } from '../types/content';
|
|
3
|
+
import type { ContentCacheStore, SingleFlightMap } from '../core/cache';
|
|
4
|
+
/**
|
|
5
|
+
* Single-flight primitive. Each factory for a given key resolves exactly once;
|
|
6
|
+
* concurrent callers share the same promise. The entry clears on settle so the
|
|
7
|
+
* next call after resolution re-runs the factory.
|
|
8
|
+
*
|
|
9
|
+
* Intentionally kept as a pure factory — no module-level state — so the store
|
|
10
|
+
* factory below can create per-store instances without cross-store leakage.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createSingleFlightMap: <T>() => SingleFlightMap<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Build a fresh content cache store. Every store has its own contents map and
|
|
15
|
+
* its own pair of single-flight maps — they do not share state with other
|
|
16
|
+
* instances. Tests should create one store per test to stay isolated.
|
|
17
|
+
*/
|
|
18
|
+
export declare const createContentCacheStore: () => ContentCacheStore<ParsedContent>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the cache store for a given request. Each event gets its own store,
|
|
21
|
+
* lazily created on first access and retained only for the request lifetime.
|
|
22
|
+
*/
|
|
23
|
+
export declare const cacheStoreFor: (event: H3Event) => ContentCacheStore<ParsedContent>;
|
|
24
|
+
/**
|
|
25
|
+
* Clear the parsed-contents cache for the active request. Useful in tests that
|
|
26
|
+
* want to force a cold read inside the same request. With request-scoped
|
|
27
|
+
* stores there is nothing meaningful to clear globally, so the eventless form
|
|
28
|
+
* is intentionally a no-op.
|
|
29
|
+
*/
|
|
30
|
+
export declare const cleanCachedContents: (event?: H3Event) => void;
|
|
31
|
+
export declare const getCachedContents: (event: H3Event, key: string) => ParsedContent[] | undefined;
|
|
32
|
+
export declare const setCachedContents: (event: H3Event, key: string, contents: ParsedContent[]) => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getContentRuntimeContext } from "../integrations/nitro/context";
|
|
2
|
+
export const createSingleFlightMap = () => {
|
|
3
|
+
const pending = /* @__PURE__ */ new Map();
|
|
4
|
+
return {
|
|
5
|
+
run(key, factory) {
|
|
6
|
+
if (!pending.has(key)) {
|
|
7
|
+
pending.set(key, Promise.resolve().then(factory).finally(() => {
|
|
8
|
+
pending.delete(key);
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
return pending.get(key);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export const createContentCacheStore = () => {
|
|
16
|
+
const contents = /* @__PURE__ */ new Map();
|
|
17
|
+
return {
|
|
18
|
+
getContents: (key) => contents.get(key),
|
|
19
|
+
setContents: (key, value) => {
|
|
20
|
+
contents.set(key, value);
|
|
21
|
+
},
|
|
22
|
+
clearContents: () => {
|
|
23
|
+
contents.clear();
|
|
24
|
+
},
|
|
25
|
+
inflightContents: createSingleFlightMap(),
|
|
26
|
+
inflightContentsList: createSingleFlightMap()
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export const cacheStoreFor = (event) => {
|
|
30
|
+
const runtime = getContentRuntimeContext(event);
|
|
31
|
+
runtime.caches ||= createContentCacheStore();
|
|
32
|
+
return runtime.caches;
|
|
33
|
+
};
|
|
34
|
+
export const cleanCachedContents = (event) => {
|
|
35
|
+
if (event) {
|
|
36
|
+
cacheStoreFor(event).clearContents();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const getCachedContents = (event, key) => cacheStoreFor(event).getContents(key);
|
|
40
|
+
export const setCachedContents = (event, key, contents) => {
|
|
41
|
+
cacheStoreFor(event).setContents(key, contents);
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content.js'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { ParsedContent } from '../types/content';
|
|
3
|
+
import type { ContentCollectionMap, ContentLocaleEntry, ContentQueryBuilderParams, ContentQueryRequest, CollectionQueryBuilder, ResolveContentReferenceOptions } from '../types/query';
|
|
4
|
+
export declare const createServerQueryFetch: <T = ParsedContent>(event: H3Event) => (query: ContentQueryRequest) => Promise<import("../types/api").ContentQueryCountResponse | {
|
|
5
|
+
result: T | T[] | undefined;
|
|
6
|
+
} | {
|
|
7
|
+
result: T | T[] | undefined;
|
|
8
|
+
skip: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
total: number;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve an authored content reference value to a concrete document.
|
|
14
|
+
*
|
|
15
|
+
* This understands locale variants, locale fallback, and collection scoping,
|
|
16
|
+
* and it augments the returned document with metadata about how the variant was
|
|
17
|
+
* resolved.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const author = await resolveContentReference(event, 'authors/evan', {
|
|
22
|
+
* collection: 'authors',
|
|
23
|
+
* locale: 'de',
|
|
24
|
+
* fallback: true
|
|
25
|
+
* })
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const resolveContentReference: <T = ParsedContent>(event: H3Event, reference: string, options?: ResolveContentReferenceOptions) => Promise<(T & {
|
|
29
|
+
_requestedLocale?: string;
|
|
30
|
+
_resolvedLocale?: string;
|
|
31
|
+
_fallback?: boolean;
|
|
32
|
+
_availableLocales?: string[];
|
|
33
|
+
_variantPaths?: Record<string, string>;
|
|
34
|
+
}) | null>;
|
|
35
|
+
export declare const createServerContentQuery: <T = ParsedContent>(event: H3Event, query?: string | ContentQueryBuilderParams, ...pathParts: string[]) => import("../types/query").ContentQueryBuilder<T>;
|
|
36
|
+
export declare function serverQueryCollection<K extends keyof ContentCollectionMap & string>(event: H3Event, collection: K): CollectionQueryBuilder<ContentCollectionMap[K]>;
|
|
37
|
+
export declare function serverQueryCollection<T = ParsedContent>(event: H3Event, collection: string): CollectionQueryBuilder<T>;
|
|
38
|
+
/**
|
|
39
|
+
* List every locale variant available for a collection entry on the server.
|
|
40
|
+
*/
|
|
41
|
+
export declare const queryCollectionLocales: <K extends keyof ContentCollectionMap & string>(event: H3Event, collection: K, identity: string) => Promise<ContentLocaleEntry[]>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { joinURL, withLeadingSlash } from "ufo";
|
|
2
|
+
import { createQuery, wrapQueryBuilder } from "../core/query/builder";
|
|
3
|
+
import { resolveGraphCanonicalKey, resolveGraphCollectionLocales, resolveGraphVariant } from "../core/content/graph";
|
|
4
|
+
import { normalizeReferenceValue } from "../core/references/resolve";
|
|
5
|
+
import { executeQueryPlan } from "../core/query/execute";
|
|
6
|
+
import { lowerQueryPlan } from "../core/query/lower";
|
|
7
|
+
import { normalizeContentQueryParams } from "../core/query/params";
|
|
8
|
+
import { normalizeI18nConfig, resolveRuntimeCollectionI18nConfig } from "../features/localization/config";
|
|
9
|
+
import { contentConfig } from "./driver.js";
|
|
10
|
+
import { withResolvedRefsQueryResponse } from "./references.js";
|
|
11
|
+
import { getContentGraph } from "./graph.js";
|
|
12
|
+
export const createServerQueryFetch = (event) => (query) => {
|
|
13
|
+
const config = contentConfig();
|
|
14
|
+
return getContentGraph(event).then((graph) => {
|
|
15
|
+
const response = executeQueryPlan(graph, lowerQueryPlan(query.params()), {
|
|
16
|
+
defaultLocale: config.defaultLocale,
|
|
17
|
+
localeFallback: config.localeFallback
|
|
18
|
+
});
|
|
19
|
+
return withResolvedRefsQueryResponse(event, response, query.params());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const resolveContentReference = async (event, reference, options = {}) => {
|
|
23
|
+
const config = contentConfig();
|
|
24
|
+
const graph = await getContentGraph(event);
|
|
25
|
+
const normalizedReference = normalizeReferenceValue(reference);
|
|
26
|
+
const canonicalId = normalizedReference ? resolveGraphCanonicalKey(graph, normalizedReference, options.collection) : null;
|
|
27
|
+
if (!canonicalId) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const variants = Object.values(graph.byCanonical[canonicalId] || {}).map((entry) => entry.document).filter((document) => !options.collection || document._collection === options.collection);
|
|
31
|
+
if (!variants.length) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const resolvedVariant = resolveGraphVariant(graph, canonicalId, options.locale, {
|
|
35
|
+
defaultLocale: config.defaultLocale,
|
|
36
|
+
fallback: Array.isArray(options.fallback) ? options.fallback : options.fallback ? config.localeFallback?.[options.locale || ""] || [] : [],
|
|
37
|
+
exact: options.exact,
|
|
38
|
+
localeFallback: config.localeFallback
|
|
39
|
+
});
|
|
40
|
+
const resolved = resolvedVariant ? graph.byId[resolvedVariant.contentId] : void 0;
|
|
41
|
+
if (!resolved || !resolvedVariant) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const availableLocales = Array.from(new Set(variants.map((document) => document._locale).filter(Boolean)));
|
|
45
|
+
const variantPaths = Object.fromEntries(
|
|
46
|
+
variants.filter((document) => document._locale && document._path).map((document) => [document._locale, document._path])
|
|
47
|
+
);
|
|
48
|
+
return {
|
|
49
|
+
...resolved,
|
|
50
|
+
_requestedLocale: resolvedVariant.requestedLocale,
|
|
51
|
+
_resolvedLocale: resolvedVariant.resolvedLocale,
|
|
52
|
+
_fallback: resolvedVariant.fallback,
|
|
53
|
+
_availableLocales: availableLocales,
|
|
54
|
+
_variantPaths: variantPaths
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const getServerCollectionI18n = (collection) => {
|
|
58
|
+
const config = contentConfig();
|
|
59
|
+
return collection ? resolveRuntimeCollectionI18nConfig(collection, config) : normalizeI18nConfig(config);
|
|
60
|
+
};
|
|
61
|
+
export const createServerContentQuery = (event, query, ...pathParts) => {
|
|
62
|
+
const config = contentConfig();
|
|
63
|
+
const queryBuilder = createQuery(createServerQueryFetch(event), { initialParams: typeof query !== "string" ? query || {} : {} });
|
|
64
|
+
let path;
|
|
65
|
+
if (typeof query === "string") {
|
|
66
|
+
path = withLeadingSlash(joinURL(query, ...pathParts));
|
|
67
|
+
}
|
|
68
|
+
return wrapQueryBuilder(queryBuilder, (params) => {
|
|
69
|
+
const collectionI18n = getServerCollectionI18n(params.collection);
|
|
70
|
+
return normalizeContentQueryParams(params, {
|
|
71
|
+
path,
|
|
72
|
+
collectionI18n,
|
|
73
|
+
defaultLocale: config.defaultLocale,
|
|
74
|
+
localeFallback: config.localeFallback,
|
|
75
|
+
activeLocale: collectionI18n?.defaultLocale,
|
|
76
|
+
includeDraftFilter: !import.meta.dev
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
export function serverQueryCollection(event, collection) {
|
|
81
|
+
return createServerContentQuery(event, { collection });
|
|
82
|
+
}
|
|
83
|
+
export const queryCollectionLocales = async (event, collection, identity) => {
|
|
84
|
+
const graph = await getContentGraph(event);
|
|
85
|
+
return resolveGraphCollectionLocales(graph, identity, collection);
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './contents.js'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { ParsedContent } from '../types/content';
|
|
3
|
+
export declare function chunksFromArray<T>(arr: T[], n: number): Generator<T[], void>;
|
|
4
|
+
export declare const getContentsList: (event: H3Event, prefix?: string) => Promise<ParsedContent[]>;
|
|
5
|
+
export declare const getContent: (event: H3Event, id: string) => Promise<ParsedContent>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { hash as ohash } from "ohash";
|
|
2
|
+
import { splitInlineLocaleVariantId } from "../core/content/locale";
|
|
3
|
+
import { memoizeRuntimeValue } from "../integrations/nitro/context";
|
|
4
|
+
import { parseContentVariants } from "../integrations/nitro/ingest";
|
|
5
|
+
import { cacheStoreFor, getCachedContents, setCachedContents } from "./cache.js";
|
|
6
|
+
import { contentConfig, contentIgnorePredicate, getContentStorageRuntime, getContentsIds, resolveStorageId } from "./driver.js";
|
|
7
|
+
import { validateContentGraph } from "./validation.js";
|
|
8
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
9
|
+
const isPrerendering = import.meta.prerender;
|
|
10
|
+
const shouldValidateAtRuntime = import.meta.dev || isPrerendering;
|
|
11
|
+
const isContentCacheArtifact = (value) => {
|
|
12
|
+
return Boolean(value) && typeof value === "object" && Array.isArray(value.parsed) && typeof value.hash === "string";
|
|
13
|
+
};
|
|
14
|
+
export function* chunksFromArray(arr, n) {
|
|
15
|
+
for (let i = 0; i < arr.length; i += n) {
|
|
16
|
+
yield arr.slice(i, i + n);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const loadContentVariants = async (event, id) => {
|
|
20
|
+
const runtime = getContentStorageRuntime(event);
|
|
21
|
+
const config = contentConfig();
|
|
22
|
+
const { sourceId: contentId } = splitInlineLocaleVariantId(id);
|
|
23
|
+
if (!contentIgnorePredicate(contentId)) {
|
|
24
|
+
return [{ _id: contentId, body: null }];
|
|
25
|
+
}
|
|
26
|
+
const storageId = await resolveStorageId(event, contentId);
|
|
27
|
+
const cachedValue = await runtime.parsedCache.getItem(storageId);
|
|
28
|
+
const cached = isContentCacheArtifact(cachedValue) ? cachedValue : null;
|
|
29
|
+
if (isProduction && !isPrerendering && cached) {
|
|
30
|
+
return cached.parsed;
|
|
31
|
+
}
|
|
32
|
+
const meta = await runtime.source.getMeta(storageId);
|
|
33
|
+
const hash = ohash({
|
|
34
|
+
mtime: meta.mtime,
|
|
35
|
+
size: meta.size || 0,
|
|
36
|
+
version: runtime.config.cacheVersion,
|
|
37
|
+
integrity: runtime.config.cacheIntegrity,
|
|
38
|
+
collections: runtime.config.collections,
|
|
39
|
+
defaultLocale: runtime.config.defaultLocale,
|
|
40
|
+
locales: runtime.config.locales,
|
|
41
|
+
translatedSlugs: runtime.config.translatedSlugs,
|
|
42
|
+
strictTranslatedSlugs: runtime.config.strictTranslatedSlugs,
|
|
43
|
+
respectPathCase: runtime.config.respectPathCase
|
|
44
|
+
});
|
|
45
|
+
if (cached?.hash === hash) {
|
|
46
|
+
return cached.parsed;
|
|
47
|
+
}
|
|
48
|
+
return cacheStoreFor(event).inflightContents.run(`${storageId}${hash}`, async () => {
|
|
49
|
+
const body = await runtime.source.getItem(storageId);
|
|
50
|
+
if (body === null) {
|
|
51
|
+
return [{ _id: contentId, body: null }];
|
|
52
|
+
}
|
|
53
|
+
const parsed = await parseContentVariants(contentId, body, config, { validate: true });
|
|
54
|
+
try {
|
|
55
|
+
await runtime.parsedCache.setItem(storageId, { parsed, hash });
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (import.meta.dev) {
|
|
58
|
+
console.warn(`[content] Failed to cache parsed content for "${storageId}"`, error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return parsed;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const loadContents = async (event, prefix) => {
|
|
65
|
+
const keys = await getContentsIds(event, prefix);
|
|
66
|
+
const contents = [];
|
|
67
|
+
for (const chunk of [...chunksFromArray(keys, 10)]) {
|
|
68
|
+
const result = await Promise.all(chunk.map((key) => loadContentVariants(event, key)));
|
|
69
|
+
contents.push(...result.flat());
|
|
70
|
+
}
|
|
71
|
+
const filtered = contents.filter((document) => document && document._path);
|
|
72
|
+
if (shouldValidateAtRuntime) {
|
|
73
|
+
const outcome = validateContentGraph(filtered, contentConfig());
|
|
74
|
+
if (!outcome.ok) {
|
|
75
|
+
throw outcome.error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return filtered;
|
|
79
|
+
};
|
|
80
|
+
export const getContentsList = (event, prefix) => {
|
|
81
|
+
const runtime = getContentStorageRuntime(event);
|
|
82
|
+
const cacheKey = JSON.stringify({
|
|
83
|
+
prefix,
|
|
84
|
+
sources: runtime.config.sources,
|
|
85
|
+
collections: runtime.config.collections,
|
|
86
|
+
defaultLocale: runtime.config.defaultLocale,
|
|
87
|
+
locales: runtime.config.locales,
|
|
88
|
+
translatedSlugs: runtime.config.translatedSlugs,
|
|
89
|
+
strictTranslatedSlugs: runtime.config.strictTranslatedSlugs
|
|
90
|
+
});
|
|
91
|
+
return memoizeRuntimeValue(event, `contents:${cacheKey}`, async () => {
|
|
92
|
+
const cached = getCachedContents(event, cacheKey);
|
|
93
|
+
if ((isPrerendering || !isProduction) && cached?.length) {
|
|
94
|
+
return cached;
|
|
95
|
+
}
|
|
96
|
+
return await cacheStoreFor(event).inflightContentsList.run(cacheKey, async () => {
|
|
97
|
+
const result = await loadContents(event, prefix);
|
|
98
|
+
if (isPrerendering || !isProduction) {
|
|
99
|
+
setCachedContents(event, cacheKey, result);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
export const getContent = async (event, id) => {
|
|
106
|
+
const { sourceId, locale } = splitInlineLocaleVariantId(id);
|
|
107
|
+
const parsed = await loadContentVariants(event, sourceId);
|
|
108
|
+
if (!locale) {
|
|
109
|
+
return parsed[0];
|
|
110
|
+
}
|
|
111
|
+
const match = parsed.find((document) => document._locale === locale);
|
|
112
|
+
if (!match) {
|
|
113
|
+
console.warn(`[content] Locale variant "${locale}" not found for "${sourceId}", falling back to default`);
|
|
114
|
+
}
|
|
115
|
+
return match || parsed[0];
|
|
116
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './driver.js'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { Storage, StorageValue } from 'unstorage';
|
|
3
|
+
import { sourceStorage, cacheStorage, cacheParsedStorage, contentConfig, contentIgnorePredicate, getContentsIds, resolveStorageId } from '../integrations/nitro/storage';
|
|
4
|
+
export interface ContentSourceDriver {
|
|
5
|
+
getKeys: (prefix?: string) => Promise<string[]>;
|
|
6
|
+
getItem: (key: string) => Promise<StorageValue | null>;
|
|
7
|
+
getMeta: (key: string) => Promise<{
|
|
8
|
+
mtime?: number;
|
|
9
|
+
size?: number;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface ContentCacheDriver {
|
|
14
|
+
getItem: <T>(key: string) => Promise<T | null>;
|
|
15
|
+
setItem: (key: string, value: unknown) => Promise<void>;
|
|
16
|
+
removeItem?: (key: string) => Promise<void>;
|
|
17
|
+
getKeys?: (prefix?: string) => Promise<string[]>;
|
|
18
|
+
}
|
|
19
|
+
export interface ContentStorageRuntime {
|
|
20
|
+
event: H3Event;
|
|
21
|
+
config: ReturnType<typeof contentConfig>;
|
|
22
|
+
source: Storage;
|
|
23
|
+
cache: Storage;
|
|
24
|
+
parsedCache: Storage;
|
|
25
|
+
now: () => Date;
|
|
26
|
+
}
|
|
27
|
+
export declare const getContentStorageRuntime: (event: H3Event) => ContentStorageRuntime;
|
|
28
|
+
export { cacheParsedStorage, cacheStorage, contentConfig, contentIgnorePredicate, getContentsIds, resolveStorageId, sourceStorage };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sourceStorage, cacheStorage, cacheParsedStorage, contentConfig, contentIgnorePredicate, getContentsIds, resolveStorageId } from "../integrations/nitro/storage";
|
|
2
|
+
import { getContentRuntimeContext } from "../integrations/nitro/context";
|
|
3
|
+
export const getContentStorageRuntime = (event) => {
|
|
4
|
+
const runtime = getContentRuntimeContext(event);
|
|
5
|
+
return {
|
|
6
|
+
event,
|
|
7
|
+
config: runtime.config || contentConfig(),
|
|
8
|
+
source: sourceStorage(event),
|
|
9
|
+
cache: cacheStorage(event),
|
|
10
|
+
parsedCache: cacheParsedStorage(event),
|
|
11
|
+
now: runtime.now || (() => /* @__PURE__ */ new Date())
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
cacheParsedStorage,
|
|
16
|
+
cacheStorage,
|
|
17
|
+
contentConfig,
|
|
18
|
+
contentIgnorePredicate,
|
|
19
|
+
getContentsIds,
|
|
20
|
+
resolveStorageId,
|
|
21
|
+
sourceStorage
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './graph.js'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { buildContentGraph } from "../core/content/graph";
|
|
2
|
+
import { memoizeRuntimeValue } from "../integrations/nitro/context";
|
|
3
|
+
import { contentConfig } from "./driver.js";
|
|
4
|
+
import { getContentsList } from "./contents.js";
|
|
5
|
+
export const getContentGraph = async (event) => {
|
|
6
|
+
return await memoizeRuntimeValue(event, "graph", async () => {
|
|
7
|
+
const config = contentConfig();
|
|
8
|
+
const contents = await getContentsList(event);
|
|
9
|
+
return buildContentGraph(contents, {
|
|
10
|
+
locales: config.locales,
|
|
11
|
+
defaultLocale: config.defaultLocale
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './manifest.js'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { H3Event } from 'h3';
|
|
2
|
+
import type { ParsedContent } from '../types/content';
|
|
3
|
+
import type { ContentLocaleEntry, ContentQueryRequest } from '../types/query';
|
|
4
|
+
import type { ContentManifest } from '../types/runtime';
|
|
5
|
+
import { resolveLocaleChain } from '../core/content/graph';
|
|
6
|
+
export { resolveLocaleChain };
|
|
7
|
+
export declare function getContentManifest(event: H3Event): Promise<ContentManifest>;
|
|
8
|
+
export declare function resolveVariant(event: H3Event, canonicalKey: string, requestedLocale?: string, options?: {
|
|
9
|
+
fallback?: string[];
|
|
10
|
+
exact?: boolean;
|
|
11
|
+
}): Promise<import("../types/runtime").ResolvedVariant | null>;
|
|
12
|
+
export declare function resolveRouteVariant(event: H3Event, routePath: string, requestedLocale?: string, options?: {
|
|
13
|
+
fallback?: string[];
|
|
14
|
+
exact?: boolean;
|
|
15
|
+
}): Promise<import("../types/runtime").ResolvedVariant | null>;
|
|
16
|
+
export declare function resolveCanonicalKey(event: H3Event, identity: string, collection?: string): Promise<string | null>;
|
|
17
|
+
export declare function resolveCollectionLocales(event: H3Event, identity: string, collection?: string): Promise<ContentLocaleEntry[]>;
|
|
18
|
+
export declare function getIndexedContentsList(event: H3Event, query: ContentQueryRequest): Promise<ParsedContent[]>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { resolveGraphCanonicalKey, resolveGraphCollectionLocales, resolveGraphRouteVariant, resolveGraphVariant, resolveLocaleChain, selectGraphDocuments } from "../core/content/graph";
|
|
2
|
+
import { collectQueryWhere } from "../core/query/params";
|
|
3
|
+
import { isPreview } from "../integrations/nitro/preview";
|
|
4
|
+
import { getContentRuntimeConfig } from "../integrations/nitro/runtime-config";
|
|
5
|
+
import { getContentsList } from "./contents.js";
|
|
6
|
+
import { cacheStorage } from "./driver.js";
|
|
7
|
+
import { getContentGraph } from "./graph.js";
|
|
8
|
+
const isManifestCacheValid = (manifest) => {
|
|
9
|
+
return Boolean(
|
|
10
|
+
manifest && typeof manifest === "object" && manifest.byCanonical && manifest.byRef && manifest.byRoute && manifest.paths && manifest.collections
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
const hasRequestContext = (event) => {
|
|
14
|
+
return Boolean(event.node?.req);
|
|
15
|
+
};
|
|
16
|
+
export { resolveLocaleChain };
|
|
17
|
+
export async function getContentManifest(event) {
|
|
18
|
+
if (!hasRequestContext(event) || !isPreview(event)) {
|
|
19
|
+
const cached = await cacheStorage(event).getItem("_manifest.json");
|
|
20
|
+
if (isManifestCacheValid(cached)) {
|
|
21
|
+
return cached;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const graph = await getContentGraph(event);
|
|
25
|
+
if (!hasRequestContext(event) || !isPreview(event)) {
|
|
26
|
+
await cacheStorage(event).setItem("_manifest.json", graph.manifest);
|
|
27
|
+
}
|
|
28
|
+
return graph.manifest;
|
|
29
|
+
}
|
|
30
|
+
export async function resolveVariant(event, canonicalKey, requestedLocale, options = {}) {
|
|
31
|
+
const config = getContentRuntimeConfig().content;
|
|
32
|
+
return resolveGraphVariant(await getContentGraph(event), canonicalKey, requestedLocale, {
|
|
33
|
+
defaultLocale: config.defaultLocale,
|
|
34
|
+
fallback: options.fallback,
|
|
35
|
+
exact: options.exact,
|
|
36
|
+
localeFallback: config.localeFallback
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export async function resolveRouteVariant(event, routePath, requestedLocale, options = {}) {
|
|
40
|
+
const config = getContentRuntimeConfig().content;
|
|
41
|
+
return resolveGraphRouteVariant(await getContentGraph(event), routePath, requestedLocale, {
|
|
42
|
+
defaultLocale: config.defaultLocale,
|
|
43
|
+
fallback: options.fallback,
|
|
44
|
+
exact: options.exact,
|
|
45
|
+
localeFallback: config.localeFallback
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export async function resolveCanonicalKey(event, identity, collection) {
|
|
49
|
+
return resolveGraphCanonicalKey(await getContentGraph(event), identity, collection);
|
|
50
|
+
}
|
|
51
|
+
export async function resolveCollectionLocales(event, identity, collection) {
|
|
52
|
+
return resolveGraphCollectionLocales(await getContentGraph(event), identity, collection);
|
|
53
|
+
}
|
|
54
|
+
export async function getIndexedContentsList(event, query) {
|
|
55
|
+
if (hasRequestContext(event) && isPreview(event)) {
|
|
56
|
+
return await getContentsList(event);
|
|
57
|
+
}
|
|
58
|
+
const params = query.params();
|
|
59
|
+
const paths = collectQueryWhere(params?.where, (where) => typeof where._path !== "undefined").map((where) => where._path).filter((path) => typeof path === "string" || path instanceof RegExp);
|
|
60
|
+
const graph = await getContentGraph(event);
|
|
61
|
+
if (!paths.length && !params?.collection) {
|
|
62
|
+
return graph.documents;
|
|
63
|
+
}
|
|
64
|
+
return selectGraphDocuments(graph, {
|
|
65
|
+
collection: params?.collection,
|
|
66
|
+
paths
|
|
67
|
+
});
|
|
68
|
+
}
|