@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,188 @@
|
|
|
1
|
+
import type { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { createError } from '#imports';
|
|
3
|
+
import type { ContentCollectionHandle } from '../../../types/config';
|
|
4
|
+
import type { BacklinksOptions, BacklinksResult, BacklinkSource, ContentVariant, ContentTreeItem, ContentResolvedMeta, DocumentFromHandle, LocalePathEntry, LocaleFallback, ManyOptions, LocalizedDoc, NeighborsOptions, NeighborsResult, OneOptions, PopulateSpec, PopulateFromOptions, PopulatedDocument, PaginationOptions, PaginationResult, ResolveOneOptions, ResolveOneResult, SortSpec, TreeOptions, VariantsOptions } from '../../../types/query';
|
|
5
|
+
type ReactiveLeaf<T> = T | MaybeRefOrGetter<T>;
|
|
6
|
+
type ReactiveValue<V> = V extends ((...args: never[]) => unknown) | readonly unknown[] ? ReactiveLeaf<V> : V extends object | undefined ? ReactiveLeaf<V> | {
|
|
7
|
+
[P in keyof NonNullable<V>]?: ReactiveLeaf<NonNullable<V>[P]>;
|
|
8
|
+
} : ReactiveLeaf<V>;
|
|
9
|
+
type Reactive<T> = {
|
|
10
|
+
[K in keyof T]: ReactiveValue<T[K]>;
|
|
11
|
+
};
|
|
12
|
+
type DocFromHandle<H> = DocumentFromHandle<H>;
|
|
13
|
+
interface UseContentOneReturn<T> {
|
|
14
|
+
data: ComputedRef<LocalizedDoc<T> | null>;
|
|
15
|
+
pending: ComputedRef<boolean>;
|
|
16
|
+
status: ComputedRef<string>;
|
|
17
|
+
error: ComputedRef<unknown>;
|
|
18
|
+
refresh: () => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reactively resolve a single document. Reruns when any reactive source on
|
|
22
|
+
* `options` changes. Caching follows Nuxt's standard `useAsyncData` semantics
|
|
23
|
+
* keyed by `${collection}:${stableHash(options)}`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useContentOne<const H extends ContentCollectionHandle | string, O extends OneOptions<H, PopulateSpec | undefined>>(handle: H, options: Reactive<O>): Promise<UseContentOneReturn<PopulatedDocument<DocFromHandle<H>, PopulateFromOptions<O>>>>;
|
|
26
|
+
type ContentPageSurroundOptions<H> = boolean | Omit<NeighborsOptions<H>, 'by' | 'locale' | 'fallback'>;
|
|
27
|
+
type ContentPageOneOptions<H, P extends PopulateSpec | undefined> = Omit<OneOptions<H, P>, 'by' | 'locale' | 'fallback'> & {
|
|
28
|
+
/**
|
|
29
|
+
* Optional locale override. Route pages may omit this even for typed i18n
|
|
30
|
+
* handles because the route selector is the source of truth for the active
|
|
31
|
+
* public URL.
|
|
32
|
+
*/
|
|
33
|
+
locale?: string;
|
|
34
|
+
fallback?: LocaleFallback;
|
|
35
|
+
};
|
|
36
|
+
export type UseContentPageOptions<H = unknown, P extends PopulateSpec | undefined = undefined> = Reactive<ContentPageOneOptions<H, P>> & {
|
|
37
|
+
/**
|
|
38
|
+
* Load previous/next items alongside the page.
|
|
39
|
+
*
|
|
40
|
+
* Pass `true` for the default neighbor query, or an options object to choose
|
|
41
|
+
* fields. The page query remains one request unless this is enabled.
|
|
42
|
+
*/
|
|
43
|
+
surround?: ContentPageSurroundOptions<H>;
|
|
44
|
+
/**
|
|
45
|
+
* Override the error raised when the current route does not resolve to a
|
|
46
|
+
* content page. Set `false` to render a local empty/not-found state.
|
|
47
|
+
*/
|
|
48
|
+
notFound?: false | (() => Parameters<typeof createError>[0]);
|
|
49
|
+
};
|
|
50
|
+
interface UseContentPageReturn<T> {
|
|
51
|
+
page: ComputedRef<LocalizedDoc<T> | undefined>;
|
|
52
|
+
surround: ComputedRef<Array<ContentTreeItem<T> | null>>;
|
|
53
|
+
pending: ComputedRef<boolean>;
|
|
54
|
+
status: ComputedRef<string>;
|
|
55
|
+
error: ComputedRef<unknown>;
|
|
56
|
+
refresh: () => Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Ergonomic route-page helper. This is the product-level default for Nuxt page
|
|
60
|
+
* components; the explicit `useContentOne` selector remains the lower-level
|
|
61
|
+
* primitive for custom reads.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useContentPage<const H extends ContentCollectionHandle | string, P extends PopulateSpec | undefined = undefined>(handle: H, options?: UseContentPageOptions<H, P>): Promise<UseContentPageReturn<PopulatedDocument<DocFromHandle<H>, P>>>;
|
|
64
|
+
interface UseContentResolveOneReturn<T> {
|
|
65
|
+
doc: ComputedRef<LocalizedDoc<T> | null>;
|
|
66
|
+
explain: ComputedRef<ResolveOneResult<T>['explain'] | null>;
|
|
67
|
+
status: ComputedRef<string>;
|
|
68
|
+
error: ComputedRef<unknown>;
|
|
69
|
+
refresh: () => Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reactively resolve a single document with a first-class diagnostic envelope.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useContentResolveOne<const H extends ContentCollectionHandle | string, O extends ResolveOneOptions<H, PopulateSpec | undefined>>(handle: H, options: Reactive<O>): Promise<UseContentResolveOneReturn<PopulatedDocument<DocFromHandle<H>, PopulateFromOptions<O>>>>;
|
|
75
|
+
interface UseContentManyReturn<T> {
|
|
76
|
+
data: ComputedRef<Array<LocalizedDoc<T>>>;
|
|
77
|
+
status: ComputedRef<string>;
|
|
78
|
+
error: ComputedRef<unknown>;
|
|
79
|
+
refresh: () => Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
interface UseContentPaginationReturn<T> {
|
|
82
|
+
data: ComputedRef<Array<LocalizedDoc<T>>>;
|
|
83
|
+
page: ComputedRef<number>;
|
|
84
|
+
limit: ComputedRef<number>;
|
|
85
|
+
total: ComputedRef<number>;
|
|
86
|
+
pageCount: ComputedRef<number>;
|
|
87
|
+
hasNext: ComputedRef<boolean>;
|
|
88
|
+
hasPrev: ComputedRef<boolean>;
|
|
89
|
+
nextPage: ComputedRef<number | null>;
|
|
90
|
+
prevPage: ComputedRef<number | null>;
|
|
91
|
+
status: ComputedRef<string>;
|
|
92
|
+
error: ComputedRef<unknown>;
|
|
93
|
+
refresh: () => Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Reactively resolve a list of documents.
|
|
97
|
+
*/
|
|
98
|
+
export declare function useContentMany<const H extends ContentCollectionHandle | string, O extends ManyOptions<H, PopulateSpec | undefined>>(handle: H, options?: Reactive<O>): Promise<UseContentManyReturn<PopulatedDocument<DocFromHandle<H>, PopulateFromOptions<O>>>>;
|
|
99
|
+
/**
|
|
100
|
+
* Reactively resolve one page of documents plus total/page navigation metadata.
|
|
101
|
+
*/
|
|
102
|
+
export declare function useContentPagination<const H extends ContentCollectionHandle | string, O extends PaginationOptions<H, PopulateSpec | undefined>>(handle: H, options: Reactive<O>): Promise<UseContentPaginationReturn<PopulatedDocument<DocFromHandle<H>, PopulateFromOptions<O>>>>;
|
|
103
|
+
interface UseContentBacklinksReturn<T> {
|
|
104
|
+
data: ComputedRef<T[]>;
|
|
105
|
+
status: ComputedRef<string>;
|
|
106
|
+
error: ComputedRef<unknown>;
|
|
107
|
+
refresh: () => Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Reactively resolve source documents that reference a target document.
|
|
111
|
+
*/
|
|
112
|
+
export declare function useContentBacklinks<const Target extends ContentCollectionHandle | string, const Source extends BacklinkSource | ReadonlyArray<BacklinkSource>, P extends PopulateSpec | undefined = undefined>(handle: Target, options: Reactive<BacklinksOptions<Target, Source, P>> & {
|
|
113
|
+
from: ReactiveValue<Source>;
|
|
114
|
+
}): Promise<UseContentBacklinksReturn<BacklinksResult<Source, P>[number]>>;
|
|
115
|
+
interface UseContentVariantsReturn<T> {
|
|
116
|
+
data: ComputedRef<Array<ContentVariant<T>>>;
|
|
117
|
+
status: ComputedRef<string>;
|
|
118
|
+
error: ComputedRef<unknown>;
|
|
119
|
+
refresh: () => Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Reactively resolve every locale variant of a single document — used by
|
|
123
|
+
* locale switchers. Returns one entry per configured locale, with a
|
|
124
|
+
* `translated` flag.
|
|
125
|
+
*/
|
|
126
|
+
export declare function useContentVariants<H extends ContentCollectionHandle | string>(handle: H, options: Reactive<VariantsOptions<H>>): Promise<UseContentVariantsReturn<DocFromHandle<H>>>;
|
|
127
|
+
interface UseContentTreeReturn<T> {
|
|
128
|
+
data: ComputedRef<T[]>;
|
|
129
|
+
status: ComputedRef<string>;
|
|
130
|
+
error: ComputedRef<unknown>;
|
|
131
|
+
refresh: () => Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Reactively resolve the navigation tree for a collection.
|
|
135
|
+
*/
|
|
136
|
+
export declare function useContentTree<H extends ContentCollectionHandle | string>(handle: H, options?: Reactive<TreeOptions<H>>): Promise<UseContentTreeReturn<ContentTreeItem<DocFromHandle<H>>>>;
|
|
137
|
+
interface UseContentNeighborsReturn<T> {
|
|
138
|
+
data: ComputedRef<NeighborsResult<T>>;
|
|
139
|
+
pending: ComputedRef<boolean>;
|
|
140
|
+
status: ComputedRef<string>;
|
|
141
|
+
error: ComputedRef<unknown>;
|
|
142
|
+
refresh: () => Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Reactively resolve previous/next surroundings for a document.
|
|
146
|
+
*/
|
|
147
|
+
export declare function useContentNeighbors<H extends ContentCollectionHandle | string>(handle: H, options: Reactive<NeighborsOptions<H>>): Promise<UseContentNeighborsReturn<DocFromHandle<H>>>;
|
|
148
|
+
interface UseContentLocaleSwitchReturn<T> {
|
|
149
|
+
/**
|
|
150
|
+
* Per-locale path map of the resolved document, keyed by locale code.
|
|
151
|
+
* Empty object when the document hasn't resolved yet or returned `null`.
|
|
152
|
+
*/
|
|
153
|
+
paths: ComputedRef<Record<string, LocalePathEntry>>;
|
|
154
|
+
/**
|
|
155
|
+
* Resolve a switch destination for a given locale. Returns the content's
|
|
156
|
+
* translated path when available; otherwise `null` so the caller can fall
|
|
157
|
+
* back to a route-only switch (e.g. `useSwitchLocalePath`).
|
|
158
|
+
*/
|
|
159
|
+
switchTo: (locale: string) => string | null;
|
|
160
|
+
/**
|
|
161
|
+
* The resolved document, exposed so the caller can read additional fields
|
|
162
|
+
* (title, description, ...) from the same query without a second fetch.
|
|
163
|
+
*/
|
|
164
|
+
data: ComputedRef<LocalizedDoc<T> | null>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Resolve every per-locale path for a content document. Thin wrapper over
|
|
168
|
+
* `useContentOne` that exposes the document's `localePaths` plus a `switchTo`
|
|
169
|
+
* helper for rendering locale switchers.
|
|
170
|
+
*
|
|
171
|
+
* Layouts and pages typically call this with the same options — `useAsyncData`
|
|
172
|
+
* dedupes by key, so it's a single round-trip:
|
|
173
|
+
*
|
|
174
|
+
* ```vue
|
|
175
|
+
* <script setup>
|
|
176
|
+
* const { switchTo } = useContentLocaleSwitch(docs, {
|
|
177
|
+
* locale: () => locale.value,
|
|
178
|
+
* by: { path: () => route.path },
|
|
179
|
+
* fallback: true
|
|
180
|
+
* })
|
|
181
|
+
*
|
|
182
|
+
* // In the template:
|
|
183
|
+
* // <a :href="switchTo('de') || useSwitchLocalePath()('de')">Deutsch</a>
|
|
184
|
+
* </script>
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare function useContentLocaleSwitch<const H extends ContentCollectionHandle | string, O extends OneOptions<H, PopulateSpec | undefined>>(handle: H, options: Reactive<O>): Promise<UseContentLocaleSwitchReturn<PopulatedDocument<DocFromHandle<H>, PopulateFromOptions<O>>>>;
|
|
188
|
+
export type { ManyOptions, OneOptions, BacklinksOptions, BacklinksResult, LocalizedDoc, ContentResolvedMeta, DocumentFromHandle, NeighborsOptions, NeighborsResult, PaginationOptions, PaginationResult, PopulateSpec, PopulateFromOptions, PopulatedDocument, ResolveOneOptions, ResolveOneResult, SortSpec, TreeOptions, VariantsOptions, ContentVariant };
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { computed, shallowRef, toValue, watch } from "vue";
|
|
2
|
+
import { hash } from "ohash";
|
|
3
|
+
import { createError, useAsyncData, useRoute } from "#imports";
|
|
4
|
+
import { createClientContentQueryContext } from "./query-api.js";
|
|
5
|
+
import {
|
|
6
|
+
backlinks as backlinksWithContext,
|
|
7
|
+
many as manyWithContext,
|
|
8
|
+
neighbors as neighborsWithContext,
|
|
9
|
+
one as oneWithContext,
|
|
10
|
+
paginate as paginateWithContext,
|
|
11
|
+
resolveOne as resolveOneWithContext,
|
|
12
|
+
tree as treeWithContext,
|
|
13
|
+
variants as variantsWithContext
|
|
14
|
+
} from "../../query/unified.js";
|
|
15
|
+
import { useContentRoute } from "./route.js";
|
|
16
|
+
const unwrapDeep = (value, seen = /* @__PURE__ */ new WeakSet()) => {
|
|
17
|
+
if (value === null || value === void 0) return value;
|
|
18
|
+
if (typeof value === "function") return unwrapDeep(toValue(value), seen);
|
|
19
|
+
if (typeof value === "object" && "__v_isRef" in value) {
|
|
20
|
+
return unwrapDeep(toValue(value), seen);
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(value)) return value.map((item) => unwrapDeep(item, seen));
|
|
23
|
+
if (typeof value === "object" && value.constructor === Object) {
|
|
24
|
+
if (seen.has(value)) return value;
|
|
25
|
+
seen.add(value);
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const [k, v] of Object.entries(value)) {
|
|
28
|
+
out[k] = unwrapDeep(v, seen);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
};
|
|
34
|
+
const resolveOptions = (reactive) => {
|
|
35
|
+
return unwrapDeep(reactive);
|
|
36
|
+
};
|
|
37
|
+
const stableKey = (prefix, name, options) => `${prefix}:${name}:${hash(options)}`;
|
|
38
|
+
export async function useContentOne(handle, options) {
|
|
39
|
+
const resolved = computed(() => resolveOptions(options));
|
|
40
|
+
const key = computed(() => stableKey("content-one", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
41
|
+
const context = createClientContentQueryContext();
|
|
42
|
+
const asyncData = await useAsyncData(
|
|
43
|
+
key,
|
|
44
|
+
() => oneWithContext(context, handle, resolved.value),
|
|
45
|
+
{ watch: [resolved], default: () => null }
|
|
46
|
+
);
|
|
47
|
+
return {
|
|
48
|
+
data: computed(() => asyncData.data.value),
|
|
49
|
+
pending: computed(() => asyncData.pending.value),
|
|
50
|
+
status: computed(() => asyncData.status.value),
|
|
51
|
+
error: computed(() => asyncData.error.value),
|
|
52
|
+
refresh: () => asyncData.refresh()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const defaultPageNotFound = () => createError({
|
|
56
|
+
statusCode: 404,
|
|
57
|
+
statusMessage: "Page not found",
|
|
58
|
+
fatal: true
|
|
59
|
+
});
|
|
60
|
+
const normalizePageNotFound = (notFound) => {
|
|
61
|
+
if (notFound === false) return void 0;
|
|
62
|
+
return createError(notFound ? notFound() : defaultPageNotFound());
|
|
63
|
+
};
|
|
64
|
+
const normalizeSurround = (surround) => {
|
|
65
|
+
if (!surround) return void 0;
|
|
66
|
+
return surround === true ? {} : surround;
|
|
67
|
+
};
|
|
68
|
+
const normalizeRoutePath = (path) => {
|
|
69
|
+
if (typeof path !== "string") return void 0;
|
|
70
|
+
const normalized = path.replace(/\/+$/, "");
|
|
71
|
+
return normalized || "/";
|
|
72
|
+
};
|
|
73
|
+
const localePathMatches = (entry, path) => {
|
|
74
|
+
const normalizedPath = normalizeRoutePath(path);
|
|
75
|
+
if (typeof entry === "string") return normalizeRoutePath(entry) === normalizedPath;
|
|
76
|
+
return Boolean(entry && typeof entry === "object" && "path" in entry && normalizeRoutePath(entry.path) === normalizedPath);
|
|
77
|
+
};
|
|
78
|
+
const routeMetaMatchesPath = (value, path) => {
|
|
79
|
+
if (!value) return false;
|
|
80
|
+
const normalizedPath = normalizeRoutePath(path);
|
|
81
|
+
const legacyPath = value;
|
|
82
|
+
if (normalizeRoutePath(legacyPath._path) === normalizedPath || normalizeRoutePath(legacyPath._requestedPath) === normalizedPath || normalizeRoutePath(legacyPath._requestedRoute) === normalizedPath) return true;
|
|
83
|
+
const requestedRoute = value.resolved?.requestedRoute ?? value._requestedRoute;
|
|
84
|
+
return normalizeRoutePath(value.path) === normalizedPath || normalizeRoutePath(value.canonicalPath) === normalizedPath || normalizeRoutePath(requestedRoute) === normalizedPath || Object.values(value.localePaths || {}).some((entry) => localePathMatches(entry, path));
|
|
85
|
+
};
|
|
86
|
+
export async function useContentPage(handle, options = {}) {
|
|
87
|
+
const route = useRoute();
|
|
88
|
+
const isBrowser = import.meta.client && typeof window !== "undefined";
|
|
89
|
+
const { notFound, surround, ...oneOptions } = options;
|
|
90
|
+
const routeSelector = { route: () => normalizeRoutePath(route.path) };
|
|
91
|
+
const rawPage = shallowRef(null);
|
|
92
|
+
const resolvingRoute = shallowRef(false);
|
|
93
|
+
const sawRouteQueryPending = shallowRef(false);
|
|
94
|
+
const page = computed(() => {
|
|
95
|
+
const current = rawPage.value;
|
|
96
|
+
return routeMetaMatchesPath(current, route.path) ? current : void 0;
|
|
97
|
+
});
|
|
98
|
+
useContentRoute(page);
|
|
99
|
+
const pageResultPromise = useContentOne(handle, {
|
|
100
|
+
...oneOptions,
|
|
101
|
+
by: routeSelector
|
|
102
|
+
});
|
|
103
|
+
const surroundOptions = normalizeSurround(surround);
|
|
104
|
+
const neighborResultPromise = surroundOptions ? useContentNeighbors(handle, {
|
|
105
|
+
...surroundOptions,
|
|
106
|
+
..."locale" in oneOptions ? { locale: oneOptions.locale } : {},
|
|
107
|
+
..."fallback" in oneOptions ? { fallback: oneOptions.fallback } : {},
|
|
108
|
+
by: routeSelector
|
|
109
|
+
}) : void 0;
|
|
110
|
+
const pageResult = await pageResultPromise;
|
|
111
|
+
rawPage.value = pageResult.data.value;
|
|
112
|
+
if (isBrowser && rawPage.value && !routeMetaMatchesPath(rawPage.value, route.path)) {
|
|
113
|
+
resolvingRoute.value = true;
|
|
114
|
+
}
|
|
115
|
+
watch(() => route.path, () => {
|
|
116
|
+
resolvingRoute.value = true;
|
|
117
|
+
sawRouteQueryPending.value = false;
|
|
118
|
+
}, { flush: "sync" });
|
|
119
|
+
watch(pageResult.data, (value) => {
|
|
120
|
+
rawPage.value = value;
|
|
121
|
+
const resolved = value;
|
|
122
|
+
if (resolved && routeMetaMatchesPath(resolved, route.path)) {
|
|
123
|
+
resolvingRoute.value = false;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
watch(() => pageResult.pending.value, (pending2) => {
|
|
127
|
+
if (pending2) {
|
|
128
|
+
sawRouteQueryPending.value = true;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (sawRouteQueryPending.value) {
|
|
132
|
+
const resolved = pageResult.data.value;
|
|
133
|
+
if (!resolved || routeMetaMatchesPath(resolved, route.path)) {
|
|
134
|
+
resolvingRoute.value = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const neighborResult = neighborResultPromise ? await neighborResultPromise : void 0;
|
|
139
|
+
const pending = computed(() => pageResult.pending.value || Boolean(neighborResult?.pending.value));
|
|
140
|
+
const pageError = computed(() => {
|
|
141
|
+
if (pageResult.error.value) return pageResult.error.value;
|
|
142
|
+
if (neighborResult?.error.value) return neighborResult.error.value;
|
|
143
|
+
if (pending.value || resolvingRoute.value || page.value || notFound === false) return void 0;
|
|
144
|
+
return normalizePageNotFound(notFound);
|
|
145
|
+
});
|
|
146
|
+
if (!isBrowser && pageError.value) {
|
|
147
|
+
throw pageError.value;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
page,
|
|
151
|
+
surround: computed(() => {
|
|
152
|
+
if (!page.value || !neighborResult) return [];
|
|
153
|
+
const neighbors = neighborResult.data.value;
|
|
154
|
+
return [neighbors.prev, neighbors.next];
|
|
155
|
+
}),
|
|
156
|
+
pending,
|
|
157
|
+
status: computed(() => pageResult.status.value),
|
|
158
|
+
error: pageError,
|
|
159
|
+
refresh: async () => {
|
|
160
|
+
await pageResult.refresh();
|
|
161
|
+
if (neighborResult) await neighborResult.refresh();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export async function useContentResolveOne(handle, options) {
|
|
166
|
+
const resolved = computed(() => resolveOptions(options));
|
|
167
|
+
const key = computed(() => stableKey("content-resolve-one", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
168
|
+
const context = createClientContentQueryContext();
|
|
169
|
+
const asyncData = await useAsyncData(
|
|
170
|
+
key,
|
|
171
|
+
() => resolveOneWithContext(context, handle, resolved.value),
|
|
172
|
+
{ watch: [resolved] }
|
|
173
|
+
);
|
|
174
|
+
return {
|
|
175
|
+
doc: computed(() => asyncData.data.value?.doc ?? null),
|
|
176
|
+
explain: computed(() => asyncData.data.value?.explain ?? null),
|
|
177
|
+
status: computed(() => asyncData.status.value),
|
|
178
|
+
error: computed(() => asyncData.error.value),
|
|
179
|
+
refresh: () => asyncData.refresh()
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
export async function useContentMany(handle, options = {}) {
|
|
183
|
+
const resolved = computed(() => resolveOptions(options));
|
|
184
|
+
const key = computed(() => stableKey("content-many", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
185
|
+
const context = createClientContentQueryContext();
|
|
186
|
+
const asyncData = await useAsyncData(
|
|
187
|
+
key,
|
|
188
|
+
() => manyWithContext(context, handle, resolved.value),
|
|
189
|
+
{ watch: [resolved], default: () => [] }
|
|
190
|
+
);
|
|
191
|
+
return {
|
|
192
|
+
data: computed(() => asyncData.data.value || []),
|
|
193
|
+
status: computed(() => asyncData.status.value),
|
|
194
|
+
error: computed(() => asyncData.error.value),
|
|
195
|
+
refresh: () => asyncData.refresh()
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const emptyPagination = () => ({
|
|
199
|
+
data: [],
|
|
200
|
+
page: 1,
|
|
201
|
+
limit: 10,
|
|
202
|
+
total: 0,
|
|
203
|
+
pageCount: 0,
|
|
204
|
+
hasNext: false,
|
|
205
|
+
hasPrev: false,
|
|
206
|
+
nextPage: null,
|
|
207
|
+
prevPage: null
|
|
208
|
+
});
|
|
209
|
+
export async function useContentPagination(handle, options) {
|
|
210
|
+
const resolved = computed(() => resolveOptions(options));
|
|
211
|
+
const key = computed(() => stableKey("content-pagination", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
212
|
+
const context = createClientContentQueryContext();
|
|
213
|
+
const asyncData = await useAsyncData(
|
|
214
|
+
key,
|
|
215
|
+
() => paginateWithContext(context, handle, resolved.value),
|
|
216
|
+
{ watch: [resolved], default: () => emptyPagination() }
|
|
217
|
+
);
|
|
218
|
+
const result = computed(() => asyncData.data.value || emptyPagination());
|
|
219
|
+
return {
|
|
220
|
+
data: computed(() => result.value.data),
|
|
221
|
+
page: computed(() => result.value.page),
|
|
222
|
+
limit: computed(() => result.value.limit),
|
|
223
|
+
total: computed(() => result.value.total),
|
|
224
|
+
pageCount: computed(() => result.value.pageCount),
|
|
225
|
+
hasNext: computed(() => result.value.hasNext),
|
|
226
|
+
hasPrev: computed(() => result.value.hasPrev),
|
|
227
|
+
nextPage: computed(() => result.value.nextPage),
|
|
228
|
+
prevPage: computed(() => result.value.prevPage),
|
|
229
|
+
status: computed(() => asyncData.status.value),
|
|
230
|
+
error: computed(() => asyncData.error.value),
|
|
231
|
+
refresh: () => asyncData.refresh()
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
export async function useContentBacklinks(handle, options) {
|
|
235
|
+
const resolved = computed(() => resolveOptions(options));
|
|
236
|
+
const key = computed(() => stableKey("content-backlinks", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
237
|
+
const context = createClientContentQueryContext();
|
|
238
|
+
const asyncData = await useAsyncData(
|
|
239
|
+
key,
|
|
240
|
+
() => backlinksWithContext(context, handle, resolved.value),
|
|
241
|
+
{ watch: [resolved], default: () => [] }
|
|
242
|
+
);
|
|
243
|
+
return {
|
|
244
|
+
data: computed(() => asyncData.data.value || []),
|
|
245
|
+
status: computed(() => asyncData.status.value),
|
|
246
|
+
error: computed(() => asyncData.error.value),
|
|
247
|
+
refresh: () => asyncData.refresh()
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export async function useContentVariants(handle, options) {
|
|
251
|
+
const resolved = computed(() => resolveOptions(options));
|
|
252
|
+
const key = computed(() => stableKey("content-variants", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
253
|
+
const context = createClientContentQueryContext();
|
|
254
|
+
const asyncData = await useAsyncData(
|
|
255
|
+
key,
|
|
256
|
+
() => variantsWithContext(context, handle, resolved.value),
|
|
257
|
+
{ watch: [resolved], default: () => [] }
|
|
258
|
+
);
|
|
259
|
+
return {
|
|
260
|
+
data: computed(() => asyncData.data.value || []),
|
|
261
|
+
status: computed(() => asyncData.status.value),
|
|
262
|
+
error: computed(() => asyncData.error.value),
|
|
263
|
+
refresh: () => asyncData.refresh()
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
export async function useContentTree(handle, options = {}) {
|
|
267
|
+
const resolved = computed(() => resolveOptions(options));
|
|
268
|
+
const key = computed(() => stableKey("content-tree", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
269
|
+
const context = createClientContentQueryContext();
|
|
270
|
+
const asyncData = await useAsyncData(
|
|
271
|
+
key,
|
|
272
|
+
() => treeWithContext(context, handle, resolved.value),
|
|
273
|
+
{ watch: [resolved], default: () => [] }
|
|
274
|
+
);
|
|
275
|
+
return {
|
|
276
|
+
data: computed(() => asyncData.data.value || []),
|
|
277
|
+
status: computed(() => asyncData.status.value),
|
|
278
|
+
error: computed(() => asyncData.error.value),
|
|
279
|
+
refresh: () => asyncData.refresh()
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export async function useContentNeighbors(handle, options) {
|
|
283
|
+
const resolved = computed(() => resolveOptions(options));
|
|
284
|
+
const key = computed(() => stableKey("content-neighbors", typeof handle === "string" ? handle : handle.name, resolved.value));
|
|
285
|
+
const context = createClientContentQueryContext();
|
|
286
|
+
const asyncData = await useAsyncData(
|
|
287
|
+
key,
|
|
288
|
+
() => neighborsWithContext(context, handle, resolved.value),
|
|
289
|
+
{ watch: [resolved], default: () => ({ prev: null, next: null }) }
|
|
290
|
+
);
|
|
291
|
+
return {
|
|
292
|
+
data: computed(() => asyncData.data.value || { prev: null, next: null }),
|
|
293
|
+
pending: computed(() => asyncData.pending.value),
|
|
294
|
+
status: computed(() => asyncData.status.value),
|
|
295
|
+
error: computed(() => asyncData.error.value),
|
|
296
|
+
refresh: () => asyncData.refresh()
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
export async function useContentLocaleSwitch(handle, options) {
|
|
300
|
+
const { data } = await useContentOne(handle, options);
|
|
301
|
+
const paths = computed(() => {
|
|
302
|
+
const localePaths = data.value?.localePaths;
|
|
303
|
+
return localePaths || {};
|
|
304
|
+
});
|
|
305
|
+
const switchTo = (locale) => paths.value?.[locale]?.path ?? null;
|
|
306
|
+
return { paths, switchTo, data };
|
|
307
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useUnwrap.js'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MarkdownNode, MarkdownRoot } from '../../../types/content';
|
|
2
|
+
declare function flatUnwrap(value: MarkdownRoot | MarkdownNode[], unwrap?: boolean | string | string[]): MarkdownNode[];
|
|
3
|
+
declare function unwrap(value: MarkdownRoot | MarkdownNode[], tags?: boolean | string | string[]): MarkdownRoot;
|
|
4
|
+
export declare const useUnwrap: () => {
|
|
5
|
+
unwrap: typeof unwrap;
|
|
6
|
+
flatUnwrap: typeof flatUnwrap;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function normalizeUnwrap(unwrap2) {
|
|
2
|
+
if (!unwrap2 || unwrap2 === true) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
return Array.isArray(unwrap2) ? unwrap2 : unwrap2.split(/\s+/).filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
function flatUnwrap(value, unwrap2 = false) {
|
|
8
|
+
const tags = normalizeUnwrap(unwrap2);
|
|
9
|
+
const nodes = Array.isArray(value) ? value : value.children;
|
|
10
|
+
if (!tags.length || nodes.length !== 1) {
|
|
11
|
+
return nodes;
|
|
12
|
+
}
|
|
13
|
+
const first = nodes[0];
|
|
14
|
+
if (!first?.tag || !tags.includes(first.tag)) {
|
|
15
|
+
return nodes;
|
|
16
|
+
}
|
|
17
|
+
return first.children || [];
|
|
18
|
+
}
|
|
19
|
+
function unwrap(value, tags = false) {
|
|
20
|
+
const nodes = flatUnwrap(value, tags);
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return {
|
|
23
|
+
type: "root",
|
|
24
|
+
children: nodes
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...value,
|
|
29
|
+
children: nodes
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export const useUnwrap = () => ({
|
|
33
|
+
unwrap,
|
|
34
|
+
flatUnwrap
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils.js'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ContentQueryBuilderParams } from '../../../types/query';
|
|
2
|
+
interface ContentRuntimeShape {
|
|
3
|
+
integrity?: string | number;
|
|
4
|
+
api: {
|
|
5
|
+
baseURL: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const withContentBase: (url: string) => string;
|
|
9
|
+
export declare const navigationDisabled: () => never;
|
|
10
|
+
export declare const addPrerenderPath: (path: string) => void;
|
|
11
|
+
export type ContentApiEndpoint = 'query' | 'navigation';
|
|
12
|
+
export type ContentApiFetcher = (request: string, init?: Record<string, unknown>) => Promise<unknown>;
|
|
13
|
+
export declare const getPreviewToken: () => string | undefined;
|
|
14
|
+
export declare const getContentApiFetcher: (fetcher?: ContentApiFetcher) => ContentApiFetcher;
|
|
15
|
+
export declare const buildContentApiPath: (endpoint: ContentApiEndpoint, params: ContentQueryBuilderParams, runtime?: ContentRuntimeShape) => string;
|
|
16
|
+
export declare const isHtmlFallbackResponse: (data: unknown) => data is string;
|
|
17
|
+
export declare function fetchContentApi<T>(endpoint: ContentApiEndpoint, params: ContentQueryBuilderParams, options?: {
|
|
18
|
+
fetcher?: ContentApiFetcher;
|
|
19
|
+
runtime?: ContentRuntimeShape;
|
|
20
|
+
notFoundMessage?: string;
|
|
21
|
+
}): Promise<T>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { withBase } from "ufo";
|
|
2
|
+
import { hash } from "ohash";
|
|
3
|
+
import { useRequestEvent, useRequestFetch } from "#imports";
|
|
4
|
+
import { encodeQueryParams } from "../../utils/query.js";
|
|
5
|
+
import { useContentPreview } from "./preview.js";
|
|
6
|
+
import { getContentRuntime } from "./runtime.js";
|
|
7
|
+
const readContentRuntime = () => getContentRuntime();
|
|
8
|
+
export const withContentBase = (url) => withBase(url, readContentRuntime().api.baseURL);
|
|
9
|
+
export const navigationDisabled = () => {
|
|
10
|
+
console.warn("Navigation is only accessible when you enable it in module options.");
|
|
11
|
+
console.warn("Learn more in the Ginko navigation documentation.");
|
|
12
|
+
throw new Error("Navigation is only accessible when you enable it in module options.");
|
|
13
|
+
};
|
|
14
|
+
const lookupRequestEvent = () => {
|
|
15
|
+
try {
|
|
16
|
+
return useRequestEvent();
|
|
17
|
+
} catch {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const addPathToEvent = (event, path) => {
|
|
22
|
+
event.node.res.setHeader(
|
|
23
|
+
"x-nitro-prerender",
|
|
24
|
+
[
|
|
25
|
+
event.node.res.getHeader("x-nitro-prerender"),
|
|
26
|
+
path
|
|
27
|
+
].filter(Boolean).join(",")
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
const createPrerenderPathAdder = () => {
|
|
31
|
+
const event = lookupRequestEvent();
|
|
32
|
+
return event ? (path) => addPathToEvent(event, path) : void 0;
|
|
33
|
+
};
|
|
34
|
+
export const addPrerenderPath = (path) => {
|
|
35
|
+
const event = lookupRequestEvent();
|
|
36
|
+
if (event) {
|
|
37
|
+
addPathToEvent(event, path);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const getPreviewToken = () => useContentPreview().getPreviewToken();
|
|
41
|
+
export const getContentApiFetcher = (fetcher) => {
|
|
42
|
+
if (fetcher) {
|
|
43
|
+
return fetcher;
|
|
44
|
+
}
|
|
45
|
+
if (import.meta.server) {
|
|
46
|
+
return useRequestFetch();
|
|
47
|
+
}
|
|
48
|
+
return $fetch;
|
|
49
|
+
};
|
|
50
|
+
export const buildContentApiPath = (endpoint, params, runtime) => {
|
|
51
|
+
const content = runtime || readContentRuntime();
|
|
52
|
+
const encodedParams = encodeQueryParams(params);
|
|
53
|
+
const requestKey = import.meta.dev ? "_" : `${hash(params)}.${content.integrity}`;
|
|
54
|
+
return withBase(`/${endpoint}/${requestKey}/${encodedParams}.json`, content.api.baseURL);
|
|
55
|
+
};
|
|
56
|
+
export const isHtmlFallbackResponse = (data) => {
|
|
57
|
+
return typeof data === "string" && data.startsWith("<!DOCTYPE html>");
|
|
58
|
+
};
|
|
59
|
+
export async function fetchContentApi(endpoint, params, options = {}) {
|
|
60
|
+
const apiPath = buildContentApiPath(endpoint, params, options.runtime);
|
|
61
|
+
const previewToken = getPreviewToken();
|
|
62
|
+
const addPrerenderPathOnSuccess = !import.meta.dev && import.meta.server ? createPrerenderPathAdder() : void 0;
|
|
63
|
+
const fetcher = getContentApiFetcher(options.fetcher);
|
|
64
|
+
const data = await fetcher(apiPath, {
|
|
65
|
+
method: "GET",
|
|
66
|
+
responseType: "json",
|
|
67
|
+
...previewToken ? { headers: { "x-nuxt-content-preview": previewToken } } : {}
|
|
68
|
+
});
|
|
69
|
+
if (isHtmlFallbackResponse(data)) {
|
|
70
|
+
throw new Error(options.notFoundMessage || "Not found");
|
|
71
|
+
}
|
|
72
|
+
if (!import.meta.dev && import.meta.server) {
|
|
73
|
+
addPrerenderPathOnSuccess?.(apiPath);
|
|
74
|
+
}
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './web-socket.js'
|