@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,80 @@
|
|
|
1
|
+
const TRANSLATED_SLUG_SEGMENT_RE = /^(\d+)\.(.+)$/;
|
|
2
|
+
const getTranslatedSlugEntries = (document, locales = []) => {
|
|
3
|
+
const file = (document._file || "").replace(/^\/+/, "");
|
|
4
|
+
const parts = file.split("/").filter(Boolean);
|
|
5
|
+
const localizedParts = parts[0] && locales.includes(parts[0]) ? parts.slice(1) : parts;
|
|
6
|
+
if (!localizedParts.length) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
const locale = document._locale || "";
|
|
10
|
+
const directories = localizedParts.slice(0, -1);
|
|
11
|
+
const basename = localizedParts[localizedParts.length - 1] || "";
|
|
12
|
+
const entries = [];
|
|
13
|
+
let parentKey = "/";
|
|
14
|
+
for (const directory of directories) {
|
|
15
|
+
const match = directory.match(TRANSLATED_SLUG_SEGMENT_RE);
|
|
16
|
+
entries.push({
|
|
17
|
+
locale,
|
|
18
|
+
file: document._file || document._id,
|
|
19
|
+
parentKey,
|
|
20
|
+
raw: directory,
|
|
21
|
+
number: match?.[1],
|
|
22
|
+
kind: "dir"
|
|
23
|
+
});
|
|
24
|
+
parentKey = match?.[1] ? `${parentKey}${parentKey === "/" ? "" : "/"}${match[1]}` : `${parentKey}${parentKey === "/" ? "" : "/"}${directory}`;
|
|
25
|
+
}
|
|
26
|
+
if (!/^index\./.test(basename) && !/^\.(navigation)(\.[^.]+)?$/.test(basename)) {
|
|
27
|
+
const match = basename.match(TRANSLATED_SLUG_SEGMENT_RE);
|
|
28
|
+
entries.push({
|
|
29
|
+
locale,
|
|
30
|
+
file: document._file || document._id,
|
|
31
|
+
parentKey,
|
|
32
|
+
raw: basename,
|
|
33
|
+
number: match?.[1],
|
|
34
|
+
kind: "file"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return entries;
|
|
38
|
+
};
|
|
39
|
+
export const collectTranslatedSlugValidationIssues = (contents, options) => {
|
|
40
|
+
if (!options.translatedSlugs) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const issues = [];
|
|
44
|
+
const seenEntries = /* @__PURE__ */ new Set();
|
|
45
|
+
const siblingNumbers = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const document of contents) {
|
|
47
|
+
const entries = getTranslatedSlugEntries(document, options.locales || []);
|
|
48
|
+
const hasMissingPrefix = entries.some((entry) => !entry.number);
|
|
49
|
+
if (hasMissingPrefix) {
|
|
50
|
+
issues.push({
|
|
51
|
+
level: "warn",
|
|
52
|
+
file: document._file || document._id,
|
|
53
|
+
reason: "translated slug mode expects numeric prefixes for localized route segments"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (!entry.number) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const entryKey = `${entry.locale}:${entry.parentKey}:${entry.kind}:${entry.raw}`;
|
|
61
|
+
if (seenEntries.has(entryKey)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
seenEntries.add(entryKey);
|
|
65
|
+
const siblingKey = `${entry.locale}:${entry.parentKey}:${entry.number}`;
|
|
66
|
+
const previous = siblingNumbers.get(siblingKey);
|
|
67
|
+
if (previous && previous.raw !== entry.raw) {
|
|
68
|
+
issues.push({
|
|
69
|
+
level: "error",
|
|
70
|
+
file: entry.file,
|
|
71
|
+
reason: `duplicate numeric prefix "${entry.number}" among localized siblings`,
|
|
72
|
+
details: `conflicts with ${previous.file}`
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
siblingNumbers.set(siblingKey, entry);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return issues;
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './build.js'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the navigation tree from a flat list of content metadata.
|
|
3
|
+
*
|
|
4
|
+
* The input is a flat list of content rows with `title`, `_path`, `_file`, and
|
|
5
|
+
* optional extra fields; the output is a `NavItem[]` tree where parent folders
|
|
6
|
+
* are synthesized from path segments and `/.navigation.yml` config entries
|
|
7
|
+
* can override titles and metadata per directory.
|
|
8
|
+
*
|
|
9
|
+
* Key behaviors to know before touching this code:
|
|
10
|
+
*
|
|
11
|
+
* - **Index-file promotion** — a `guide/index.md` becomes the `guide`
|
|
12
|
+
* folder's own nav entry, not a child. Its siblings-under-`guide`
|
|
13
|
+
* become its children.
|
|
14
|
+
* - **`.navigation.yml`** — `configs['/guide']` can set `navigation: false`
|
|
15
|
+
* on a directory to hide the entire subtree from navigation; or
|
|
16
|
+
* override `title`/other fields.
|
|
17
|
+
* - **Natural sort** — siblings sort by `_file` (filename without the
|
|
18
|
+
* extension) via `Intl.Collator({ numeric: true })`, so `10-foo` comes
|
|
19
|
+
* after `2-foo`, not between `1-foo` and `20-foo`.
|
|
20
|
+
* - **Two-pass shaping** — we build a mutable canonical tree, then project it
|
|
21
|
+
* into the public navigation contract. Synthetic folders keep canonical
|
|
22
|
+
* identity internally and become pathless public groups at the projection
|
|
23
|
+
* boundary.
|
|
24
|
+
*/
|
|
25
|
+
import type { NavItem, ParsedContentMeta } from '../../types/content';
|
|
26
|
+
import { type CanonicalNavigationItem } from './canonical';
|
|
27
|
+
export declare const buildCanonicalNavigation: (contents: ParsedContentMeta[], configs: Record<string, ParsedContentMeta>, fields?: string[]) => CanonicalNavigationItem[];
|
|
28
|
+
export declare const buildNavigation: (contents: ParsedContentMeta[], configs: Record<string, ParsedContentMeta>, fields?: string[]) => NavItem[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { generateTitle } from "../../core/content/path";
|
|
2
|
+
import { projectNavigationTree } from "./canonical.js";
|
|
3
|
+
const collator = new Intl.Collator(void 0, { numeric: true, sensitivity: "base" });
|
|
4
|
+
const pick = (keys) => (obj) => {
|
|
5
|
+
const target = obj || {};
|
|
6
|
+
if (!keys?.length) {
|
|
7
|
+
return target;
|
|
8
|
+
}
|
|
9
|
+
return keys.filter((key) => typeof target[key] !== "undefined").reduce((newObject, key) => Object.assign(newObject, { [key]: target[key] }), {});
|
|
10
|
+
};
|
|
11
|
+
const isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
|
|
12
|
+
const parentCanonicalKey = (content, depth) => {
|
|
13
|
+
const canonicalKey = content._canonicalKey;
|
|
14
|
+
if (typeof canonicalKey !== "string" || !canonicalKey) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
return canonicalKey.split("/").slice(0, depth + 1).join("/") || void 0;
|
|
18
|
+
};
|
|
19
|
+
const sortCanonicalTree = (items) => {
|
|
20
|
+
items.forEach((item) => {
|
|
21
|
+
if (item._file) {
|
|
22
|
+
item._file = item._file.split(".").slice(0, -1).join(".");
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const sorted = items.sort((left, right) => collator.compare(left._file || "", right._file || ""));
|
|
26
|
+
for (const item of sorted) {
|
|
27
|
+
if (item.children?.length) {
|
|
28
|
+
sortCanonicalTree(item.children);
|
|
29
|
+
} else {
|
|
30
|
+
delete item.children;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return items;
|
|
34
|
+
};
|
|
35
|
+
export const buildCanonicalNavigation = (contents, configs, fields = []) => {
|
|
36
|
+
const pickNavigationFields = (content) => ({
|
|
37
|
+
...pick(["title", ...fields])(content),
|
|
38
|
+
...isObject(content?.navigation) ? content.navigation : {}
|
|
39
|
+
});
|
|
40
|
+
const navigation = contents.sort((left, right) => left._path.localeCompare(right._path)).reduce((nav, content) => {
|
|
41
|
+
const parts = content._path.substring(1).split("/");
|
|
42
|
+
const idParts = content._id.split(":").slice(1);
|
|
43
|
+
const isIndex = Boolean(idParts[idParts.length - 1]?.match(/([1-9][0-9]*\.)?index.md/g));
|
|
44
|
+
const navItem = {
|
|
45
|
+
title: content.title,
|
|
46
|
+
_path: content._path,
|
|
47
|
+
path: content._path,
|
|
48
|
+
_file: content._file,
|
|
49
|
+
_id: content._id,
|
|
50
|
+
_canonicalKey: content._canonicalKey,
|
|
51
|
+
_locale: content._locale,
|
|
52
|
+
_navigationKind: "page",
|
|
53
|
+
_navigationPath: content._path,
|
|
54
|
+
children: [],
|
|
55
|
+
...pickNavigationFields(content),
|
|
56
|
+
...content._draft ? { _draft: true } : {}
|
|
57
|
+
};
|
|
58
|
+
if (isIndex) {
|
|
59
|
+
const dirConfig = configs[navItem._path];
|
|
60
|
+
if (typeof dirConfig?.navigation !== "undefined" && !dirConfig.navigation) {
|
|
61
|
+
return nav;
|
|
62
|
+
}
|
|
63
|
+
if (dirConfig) {
|
|
64
|
+
Object.assign(navItem, pickNavigationFields(dirConfig));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (parts.length === 1) {
|
|
68
|
+
nav.push(navItem);
|
|
69
|
+
return nav;
|
|
70
|
+
}
|
|
71
|
+
const siblings = parts.slice(0, -1).reduce((nodes, part, index) => {
|
|
72
|
+
const currentPathPart = `/${parts.slice(0, index + 1).join("/")}`;
|
|
73
|
+
const config = configs[currentPathPart];
|
|
74
|
+
if (typeof config?.navigation !== "undefined" && !config.navigation) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
let parent = nodes.find((node) => node.path === currentPathPart);
|
|
78
|
+
if (!parent) {
|
|
79
|
+
const canonicalKey = parentCanonicalKey(content, index);
|
|
80
|
+
parent = {
|
|
81
|
+
title: generateTitle(part),
|
|
82
|
+
_path: currentPathPart,
|
|
83
|
+
path: currentPathPart,
|
|
84
|
+
_file: content._file,
|
|
85
|
+
_navigationKind: "folder",
|
|
86
|
+
_navigationPath: currentPathPart,
|
|
87
|
+
page: false,
|
|
88
|
+
...canonicalKey ? { _canonicalKey: canonicalKey } : {},
|
|
89
|
+
...content._locale ? { _locale: content._locale } : {},
|
|
90
|
+
children: [],
|
|
91
|
+
...config && pickNavigationFields(config)
|
|
92
|
+
};
|
|
93
|
+
nodes.push(parent);
|
|
94
|
+
}
|
|
95
|
+
return parent.children;
|
|
96
|
+
}, nav);
|
|
97
|
+
siblings.push(navItem);
|
|
98
|
+
return nav;
|
|
99
|
+
}, []);
|
|
100
|
+
return sortCanonicalTree(navigation);
|
|
101
|
+
};
|
|
102
|
+
export const buildNavigation = (contents, configs, fields = []) => {
|
|
103
|
+
return projectNavigationTree(buildCanonicalNavigation(contents, configs, fields));
|
|
104
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './canonical.js'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ContentNavigationItem, NavItem } from '../../types/content';
|
|
2
|
+
import { type RouteMounts } from '../localization/path';
|
|
3
|
+
export type NavigationNodeKind = 'page' | 'folder';
|
|
4
|
+
export interface CanonicalNavigationItem {
|
|
5
|
+
title: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
_path?: string;
|
|
8
|
+
stem?: string;
|
|
9
|
+
page?: false;
|
|
10
|
+
_id?: string;
|
|
11
|
+
_canonicalKey?: string;
|
|
12
|
+
_locale?: string;
|
|
13
|
+
_fallback?: boolean;
|
|
14
|
+
_draft?: boolean;
|
|
15
|
+
_file?: string;
|
|
16
|
+
_navigationKind?: NavigationNodeKind;
|
|
17
|
+
_navigationPath?: string;
|
|
18
|
+
_collectionRoot?: string;
|
|
19
|
+
children?: CanonicalNavigationItem[];
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface ProjectNavigationOptions {
|
|
23
|
+
locale?: string;
|
|
24
|
+
defaultLocale?: string;
|
|
25
|
+
routeMounts?: RouteMounts;
|
|
26
|
+
collection?: string;
|
|
27
|
+
canonical?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare const getNavigationIdentity: (node: Pick<CanonicalNavigationItem, "_canonicalKey" | "_path" | "_id">) => string | undefined;
|
|
30
|
+
export declare const mergeCanonicalNavigation: (primary?: CanonicalNavigationItem[], fallback?: CanonicalNavigationItem[]) => CanonicalNavigationItem[];
|
|
31
|
+
export declare const markCollectionNavigationRoot: (navigation?: CanonicalNavigationItem[], collection?: string, options?: Pick<ProjectNavigationOptions, "routeMounts">) => CanonicalNavigationItem[];
|
|
32
|
+
export declare const scopeNavigationTree: (navigation?: CanonicalNavigationItem[], collection?: string) => CanonicalNavigationItem[];
|
|
33
|
+
export declare const projectNavigationTree: (navigation?: CanonicalNavigationItem[] | NavItem[], options?: ProjectNavigationOptions) => ContentNavigationItem[];
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { getContentStem, normalizeContentPath, projectContentPathToLocale } from "../localization/path.js";
|
|
2
|
+
const isString = (value) => typeof value === "string" && value.length > 0;
|
|
3
|
+
export const getNavigationIdentity = (node) => {
|
|
4
|
+
if (isString(node._canonicalKey)) {
|
|
5
|
+
return node._canonicalKey;
|
|
6
|
+
}
|
|
7
|
+
return void 0;
|
|
8
|
+
};
|
|
9
|
+
const cloneFallbackNode = (node) => ({
|
|
10
|
+
...node,
|
|
11
|
+
_fallback: true,
|
|
12
|
+
children: node.children?.map(cloneFallbackNode)
|
|
13
|
+
});
|
|
14
|
+
export const mergeCanonicalNavigation = (primary = [], fallback = []) => {
|
|
15
|
+
const merged = primary.map((item) => ({
|
|
16
|
+
...item,
|
|
17
|
+
children: item.children ? mergeCanonicalNavigation(item.children, []) : void 0
|
|
18
|
+
}));
|
|
19
|
+
const index = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const item of merged) {
|
|
21
|
+
const identity = getNavigationIdentity(item);
|
|
22
|
+
if (identity) {
|
|
23
|
+
index.set(identity, item);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (const fallbackItem of fallback) {
|
|
27
|
+
const identity = getNavigationIdentity(fallbackItem);
|
|
28
|
+
if (!identity) {
|
|
29
|
+
merged.push(cloneFallbackNode(fallbackItem));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const existing = index.get(identity);
|
|
33
|
+
if (!existing) {
|
|
34
|
+
const clone = cloneFallbackNode(fallbackItem);
|
|
35
|
+
merged.push(clone);
|
|
36
|
+
index.set(identity, clone);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
for (const [field, value] of Object.entries(fallbackItem)) {
|
|
40
|
+
if (field === "children") {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (typeof existing[field] === "undefined" && typeof value !== "undefined") {
|
|
44
|
+
existing[field] = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
existing.children = mergeCanonicalNavigation(existing.children || [], fallbackItem.children || []);
|
|
48
|
+
}
|
|
49
|
+
return merged;
|
|
50
|
+
};
|
|
51
|
+
const normalizeRoutePath = (path) => {
|
|
52
|
+
if (!isString(path)) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
return normalizeContentPath(path);
|
|
56
|
+
};
|
|
57
|
+
const isFolderNode = (item) => {
|
|
58
|
+
if (item._navigationKind === "folder") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (item._navigationKind === "page") {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return Boolean(item.children?.length && !item._id && !item._path && !item.path);
|
|
65
|
+
};
|
|
66
|
+
const matchesCollectionRootConfig = (collection, root, options) => {
|
|
67
|
+
if (!root.children?.length) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const identity = getNavigationIdentity(root);
|
|
71
|
+
if (identity === collection || identity === `/${collection}`) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
const rootPath = normalizeRoutePath(root._path || root._navigationPath || root.path);
|
|
75
|
+
if (rootPath === "/" || rootPath === `/${collection}`) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (rootPath && Object.values(options.routeMounts || {}).map(normalizeContentPath).includes(rootPath)) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
};
|
|
83
|
+
export const markCollectionNavigationRoot = (navigation = [], collection, options = {}) => {
|
|
84
|
+
if (!collection || navigation.length !== 1) {
|
|
85
|
+
return navigation;
|
|
86
|
+
}
|
|
87
|
+
const [root] = navigation;
|
|
88
|
+
if (!root || root._collectionRoot === collection || !matchesCollectionRootConfig(collection, root, options)) {
|
|
89
|
+
return navigation;
|
|
90
|
+
}
|
|
91
|
+
return [{ ...root, _collectionRoot: collection }];
|
|
92
|
+
};
|
|
93
|
+
export const scopeNavigationTree = (navigation = [], collection) => {
|
|
94
|
+
if (!collection || navigation.length !== 1) {
|
|
95
|
+
return navigation;
|
|
96
|
+
}
|
|
97
|
+
const [root] = navigation;
|
|
98
|
+
if (!root?.children?.length || root._collectionRoot !== collection) {
|
|
99
|
+
return navigation;
|
|
100
|
+
}
|
|
101
|
+
return root.children;
|
|
102
|
+
};
|
|
103
|
+
const publicFields = (item) => {
|
|
104
|
+
const {
|
|
105
|
+
children: _children,
|
|
106
|
+
path: _path,
|
|
107
|
+
_path: _canonicalPath,
|
|
108
|
+
stem: _stem,
|
|
109
|
+
_file,
|
|
110
|
+
_navigationKind,
|
|
111
|
+
_navigationPath,
|
|
112
|
+
_collectionRoot,
|
|
113
|
+
...fields
|
|
114
|
+
} = item;
|
|
115
|
+
return fields;
|
|
116
|
+
};
|
|
117
|
+
const projectNavigationItem = (item, options) => {
|
|
118
|
+
const children = item.children?.map((child) => projectNavigationItem(child, options)).filter(Boolean);
|
|
119
|
+
const hasChildren = Boolean(children?.length);
|
|
120
|
+
const base = {
|
|
121
|
+
...publicFields(item),
|
|
122
|
+
_fallback: item._fallback === true
|
|
123
|
+
};
|
|
124
|
+
if (isFolderNode(item)) {
|
|
125
|
+
return {
|
|
126
|
+
...base,
|
|
127
|
+
...hasChildren ? { children } : {}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const rawPath = item._path || item._navigationPath || item.path;
|
|
131
|
+
if (!rawPath) {
|
|
132
|
+
return {
|
|
133
|
+
...base,
|
|
134
|
+
...hasChildren ? { children } : {}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const canonicalPath = normalizeContentPath(rawPath);
|
|
138
|
+
return {
|
|
139
|
+
...base,
|
|
140
|
+
_path: canonicalPath,
|
|
141
|
+
path: options.canonical ? canonicalPath : projectContentPathToLocale(canonicalPath, options.locale || item._locale, options.defaultLocale, options.routeMounts),
|
|
142
|
+
canonicalPath,
|
|
143
|
+
stem: item.stem || getContentStem(canonicalPath, item._file),
|
|
144
|
+
...hasChildren ? { children } : {}
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export const projectNavigationTree = (navigation = [], options = {}) => {
|
|
148
|
+
return scopeNavigationTree(navigation, options.collection).map((item) => projectNavigationItem(item, options));
|
|
149
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './query.js'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NavItem } from '../../types/content';
|
|
2
|
+
import type { ContentQueryBuilderParams } from '../../types/query';
|
|
3
|
+
export interface ResolveNavigationRuntime {
|
|
4
|
+
defaultLocale?: string;
|
|
5
|
+
localeFallback?: Record<string, string[]>;
|
|
6
|
+
navigation: false | {
|
|
7
|
+
fields: string[];
|
|
8
|
+
};
|
|
9
|
+
cacheEnabled: boolean;
|
|
10
|
+
isPreview: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolveNavigationOptions {
|
|
13
|
+
query?: ContentQueryBuilderParams;
|
|
14
|
+
readCache?: () => Promise<NavItem[] | null>;
|
|
15
|
+
loadLocaleNavigation: (locale?: string) => Promise<NavItem[]>;
|
|
16
|
+
resolveLocaleChain: (requestedLocale?: string, defaultLocale?: string, fallback?: Record<string, string[]>) => string[];
|
|
17
|
+
localizeNavigation?: (items: NavItem[], locale?: string, fallback?: string[], collection?: string, canonical?: boolean) => Promise<NavItem[]>;
|
|
18
|
+
}
|
|
19
|
+
export declare const resolveContentNavigationData: (runtime: ResolveNavigationRuntime, { query: inputQuery, readCache, loadLocaleNavigation, resolveLocaleChain, localizeNavigation }: ResolveNavigationOptions) => Promise<NavItem[]>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { buildLocaleFallbackChain } from "../../core/content/locale";
|
|
2
|
+
import { mergeCanonicalNavigation, projectNavigationTree } from "./canonical.js";
|
|
3
|
+
export const resolveContentNavigationData = async (runtime, {
|
|
4
|
+
query: inputQuery = {},
|
|
5
|
+
readCache,
|
|
6
|
+
loadLocaleNavigation,
|
|
7
|
+
resolveLocaleChain,
|
|
8
|
+
localizeNavigation
|
|
9
|
+
}) => {
|
|
10
|
+
const query = { ...inputQuery };
|
|
11
|
+
const resolveLocale = query.resolveLocale;
|
|
12
|
+
if (resolveLocale) {
|
|
13
|
+
delete query.resolveLocale;
|
|
14
|
+
}
|
|
15
|
+
const canonical = query.canonical === true;
|
|
16
|
+
if ("canonical" in query) {
|
|
17
|
+
delete query.canonical;
|
|
18
|
+
}
|
|
19
|
+
if ("navigationFields" in query) {
|
|
20
|
+
delete query.navigationFields;
|
|
21
|
+
}
|
|
22
|
+
if (runtime.navigation === false) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
if (runtime.cacheEnabled && !runtime.isPreview && !resolveLocale && Object.keys(query).length === 0 && readCache) {
|
|
26
|
+
const cache = await readCache();
|
|
27
|
+
if (cache) {
|
|
28
|
+
return cache;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const requestedLocale = resolveLocale?.locale;
|
|
32
|
+
const collection = typeof query.collection === "string" ? query.collection : void 0;
|
|
33
|
+
const fallback = requestedLocale && resolveLocale?.fallback === true ? buildLocaleFallbackChain(requestedLocale, runtime.defaultLocale, runtime.localeFallback) : Array.isArray(resolveLocale?.fallback) ? resolveLocale.fallback : [];
|
|
34
|
+
const localeChain = resolveLocale ? resolveLocale.exact || resolveLocale.fallback === false ? [requestedLocale].filter(Boolean) : resolveLocaleChain(
|
|
35
|
+
requestedLocale,
|
|
36
|
+
runtime.defaultLocale,
|
|
37
|
+
requestedLocale ? { [requestedLocale]: fallback } : {}
|
|
38
|
+
) : [requestedLocale].filter(Boolean);
|
|
39
|
+
if (!localeChain.length) {
|
|
40
|
+
const navigation = await loadLocaleNavigation(requestedLocale);
|
|
41
|
+
return localizeNavigation ? await localizeNavigation(navigation, requestedLocale, [], collection, canonical) : projectNavigationTree(navigation, { locale: requestedLocale, defaultLocale: runtime.defaultLocale, collection, canonical });
|
|
42
|
+
}
|
|
43
|
+
let mergedNavigation = [];
|
|
44
|
+
let first = true;
|
|
45
|
+
for (const locale of localeChain) {
|
|
46
|
+
const navigation = await loadLocaleNavigation(locale);
|
|
47
|
+
mergedNavigation = first ? navigation : mergeCanonicalNavigation(mergedNavigation, navigation);
|
|
48
|
+
first = false;
|
|
49
|
+
}
|
|
50
|
+
return localizeNavigation ? await localizeNavigation(mergedNavigation, requestedLocale, fallback, collection, canonical) : projectNavigationTree(mergedNavigation, { locale: requestedLocale, defaultLocale: runtime.defaultLocale, collection, canonical });
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolve.js'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ContentNavigationItem } from '../../types/content';
|
|
2
|
+
export type ContentNavigationMatch = {
|
|
3
|
+
path?: string;
|
|
4
|
+
stem?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
};
|
|
7
|
+
export type ResolvedContentNavigationItem = ContentNavigationItem & {
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getNavigationItemPath: (item: ContentNavigationItem | null | undefined) => string | undefined;
|
|
11
|
+
export declare const resolveNavigationItem: (item: ContentNavigationItem | null | undefined) => ResolvedContentNavigationItem | null;
|
|
12
|
+
export declare const matchesNavigationItem: (item: ContentNavigationItem, match: string | ContentNavigationMatch) => boolean;
|
|
13
|
+
export declare const findFirstNavigationPage: (items?: ContentNavigationItem[]) => ResolvedContentNavigationItem | null;
|
|
14
|
+
export declare const findFirstNavigationChild: (item: ContentNavigationItem | null | undefined) => ResolvedContentNavigationItem | null;
|
|
15
|
+
export declare const findNavigationItem: (items: ContentNavigationItem[] | undefined, match: number | string | ContentNavigationMatch, options?: {
|
|
16
|
+
recursive?: boolean;
|
|
17
|
+
}) => ContentNavigationItem | null;
|
|
18
|
+
export declare const resolveNavigationPaths: (items?: ContentNavigationItem[]) => string[];
|
|
19
|
+
export declare const resolveNavigationFirstPages: (items?: ContentNavigationItem[]) => ResolvedContentNavigationItem[];
|
|
20
|
+
export declare const resolveNavigationFirstChildren: (items?: ContentNavigationItem[]) => ResolvedContentNavigationItem[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const normalizePath = (path) => path !== "/" && path.endsWith("/") ? path.slice(0, -1) : path;
|
|
2
|
+
const stringValue = (value) => typeof value === "string" && value.length ? value : void 0;
|
|
3
|
+
export const getNavigationItemPath = (item) => {
|
|
4
|
+
if (!item || item.page === false) {
|
|
5
|
+
return void 0;
|
|
6
|
+
}
|
|
7
|
+
return stringValue(item.path) || stringValue(item._path);
|
|
8
|
+
};
|
|
9
|
+
export const resolveNavigationItem = (item) => {
|
|
10
|
+
const path = getNavigationItemPath(item);
|
|
11
|
+
return item && path ? { ...item, path } : null;
|
|
12
|
+
};
|
|
13
|
+
const fieldMatches = (item, field, value) => {
|
|
14
|
+
const candidate = stringValue(item[field]);
|
|
15
|
+
if (!candidate) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (field === "path" || field === "_path" || field === "canonicalPath") {
|
|
19
|
+
return normalizePath(candidate) === normalizePath(value);
|
|
20
|
+
}
|
|
21
|
+
return candidate === value;
|
|
22
|
+
};
|
|
23
|
+
export const matchesNavigationItem = (item, match) => {
|
|
24
|
+
if (typeof match === "string") {
|
|
25
|
+
return fieldMatches(item, "path", match) || fieldMatches(item, "_path", match) || fieldMatches(item, "canonicalPath", match) || fieldMatches(item, "stem", match) || fieldMatches(item, "title", match);
|
|
26
|
+
}
|
|
27
|
+
if (match.path && !(fieldMatches(item, "path", match.path) || fieldMatches(item, "_path", match.path) || fieldMatches(item, "canonicalPath", match.path))) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (match.stem && !fieldMatches(item, "stem", match.stem)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (match.title && !fieldMatches(item, "title", match.title)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return Boolean(match.path || match.stem || match.title);
|
|
37
|
+
};
|
|
38
|
+
export const findFirstNavigationPage = (items = []) => {
|
|
39
|
+
for (const item of items) {
|
|
40
|
+
const resolved = resolveNavigationItem(item);
|
|
41
|
+
if (resolved) {
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
const child = findFirstNavigationPage(item.children);
|
|
45
|
+
if (child) {
|
|
46
|
+
return child;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
51
|
+
export const findFirstNavigationChild = (item) => {
|
|
52
|
+
return findFirstNavigationPage(item?.children || []);
|
|
53
|
+
};
|
|
54
|
+
export const findNavigationItem = (items = [], match, options = {}) => {
|
|
55
|
+
if (typeof match === "number") {
|
|
56
|
+
return items[match] || null;
|
|
57
|
+
}
|
|
58
|
+
for (const item of items) {
|
|
59
|
+
if (matchesNavigationItem(item, match)) {
|
|
60
|
+
return item;
|
|
61
|
+
}
|
|
62
|
+
if (options.recursive) {
|
|
63
|
+
const child = findNavigationItem(item.children, match, options);
|
|
64
|
+
if (child) {
|
|
65
|
+
return child;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
export const resolveNavigationPaths = (items = []) => {
|
|
72
|
+
return items.map((item) => resolveNavigationItem(item)?.path).filter((path) => Boolean(path));
|
|
73
|
+
};
|
|
74
|
+
export const resolveNavigationFirstPages = (items = []) => {
|
|
75
|
+
return items.map((item) => resolveNavigationItem(item) || findFirstNavigationChild(item)).filter((item) => Boolean(item));
|
|
76
|
+
};
|
|
77
|
+
export const resolveNavigationFirstChildren = (items = []) => {
|
|
78
|
+
return items.map((item) => findFirstNavigationChild(item)).filter((item) => Boolean(item));
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree.js'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ContentNavigationItem } from '../../types/content';
|
|
2
|
+
export declare function flattenCollectionNavigation(navigation?: ContentNavigationItem[]): ContentNavigationItem[];
|
|
3
|
+
export declare function createCollectionSurroundings(navigation: ContentNavigationItem[] | undefined, path: string, options?: Partial<{
|
|
4
|
+
before: number;
|
|
5
|
+
after: number;
|
|
6
|
+
}>): Array<ContentNavigationItem | null>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function flattenCollectionNavigation(navigation = []) {
|
|
2
|
+
return navigation.flatMap((item) => {
|
|
3
|
+
const children = item.children ? flattenCollectionNavigation(item.children) : [];
|
|
4
|
+
if (!item._path && !item.path) {
|
|
5
|
+
return children;
|
|
6
|
+
}
|
|
7
|
+
if (item.page === false || children.length && children.find((child) => child._path === item._path)) {
|
|
8
|
+
return children;
|
|
9
|
+
}
|
|
10
|
+
return [{ ...item, children: void 0 }, ...children];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function createCollectionSurroundings(navigation = [], path, options = {}) {
|
|
14
|
+
const before = options.before ?? 1;
|
|
15
|
+
const after = options.after ?? 1;
|
|
16
|
+
const items = flattenCollectionNavigation(navigation);
|
|
17
|
+
const normalizedPath = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
|
|
18
|
+
const index = items.findIndex((item) => {
|
|
19
|
+
const itemPath = typeof item.path === "string" ? item.path : item._path;
|
|
20
|
+
if (!itemPath) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const normalizedItemPath = itemPath.endsWith("/") && itemPath !== "/" ? itemPath.slice(0, -1) : itemPath;
|
|
24
|
+
return normalizedItemPath === normalizedPath;
|
|
25
|
+
});
|
|
26
|
+
const beforeItems = index === -1 ? [] : items.slice(Math.max(0, index - before), index);
|
|
27
|
+
const afterItems = index === -1 ? [] : items.slice(index + 1, index + after + 1);
|
|
28
|
+
return [
|
|
29
|
+
...Array.from({ length: before }).fill(null).concat(beforeItems).slice(beforeItems.length),
|
|
30
|
+
...afterItems.concat(Array.from({ length: after }).fill(null)).slice(0, after)
|
|
31
|
+
];
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navigation.js'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ContentNavigationItem } from '../../types/content';
|
|
2
|
+
/**
|
|
3
|
+
* Convert normal content navigation into the leaf-oriented shape expected by
|
|
4
|
+
* Nuxt UI's UContentSearch without mutating the source navigation tree.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createContentSearchNavigation(items?: ContentNavigationItem[], depth?: number): ContentNavigationItem[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const itemPath = (item) => item.path || item._path;
|
|
2
|
+
const searchGroupId = (item, depth, index) => `content-search-group:${String(item._canonicalKey || item.stem || `${depth}:${index}`)}`;
|
|
3
|
+
export function createContentSearchNavigation(items = [], depth = 0) {
|
|
4
|
+
return items.map((item, index) => {
|
|
5
|
+
const children = item.children ? createContentSearchNavigation(item.children, depth + 1) : [];
|
|
6
|
+
const path = itemPath(item);
|
|
7
|
+
const hasSelfChild = children.some((child) => itemPath(child) === path);
|
|
8
|
+
const normalizedItem = {
|
|
9
|
+
...item,
|
|
10
|
+
...path && !item.path ? { path } : {},
|
|
11
|
+
...!path ? { searchGroupId: searchGroupId(item, depth, index) } : {}
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
...normalizedItem,
|
|
15
|
+
children: children.length ? [
|
|
16
|
+
...path && !hasSelfChild ? [{ ...normalizedItem, children: void 0 }] : [],
|
|
17
|
+
...children
|
|
18
|
+
] : void 0
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sections.js'
|