@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,150 @@
|
|
|
1
|
+
import { computed, onScopeDispose, toValue, watch } from "vue";
|
|
2
|
+
import { useRoute, useRouter, useState } from "#imports";
|
|
3
|
+
import { useRouteBaseName, useSetI18nParams, useSwitchLocalePath } from "./content-i18n.js";
|
|
4
|
+
const CONTENT_ROUTE_META_KEY = "__nuxt_content_route";
|
|
5
|
+
const CONTENT_ROUTE_REGISTRY_KEY = "__nuxt_content_route_registry";
|
|
6
|
+
const CONTENT_ROUTE_STATE_KEY = "nuxt-content-route";
|
|
7
|
+
let contentRouteTokenId = 0;
|
|
8
|
+
const getRouteMetaState = (meta) => meta[CONTENT_ROUTE_META_KEY];
|
|
9
|
+
const getRoutePublisherRegistry = (meta) => meta[CONTENT_ROUTE_REGISTRY_KEY];
|
|
10
|
+
const getActiveRoutePublisher = (meta) => {
|
|
11
|
+
const registry = getRoutePublisherRegistry(meta);
|
|
12
|
+
if (!registry) {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return Object.values(registry).sort((left, right) => right.order - left.order)[0];
|
|
16
|
+
};
|
|
17
|
+
const syncPublishedContentRoute = (meta, setI18nParams) => {
|
|
18
|
+
const activePublisher = getActiveRoutePublisher(meta);
|
|
19
|
+
if (!activePublisher) {
|
|
20
|
+
Reflect.deleteProperty(meta, CONTENT_ROUTE_META_KEY);
|
|
21
|
+
Reflect.deleteProperty(meta, CONTENT_ROUTE_REGISTRY_KEY);
|
|
22
|
+
setI18nParams({});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
meta[CONTENT_ROUTE_META_KEY] = {
|
|
26
|
+
token: activePublisher.token,
|
|
27
|
+
path: activePublisher.path,
|
|
28
|
+
canonicalPath: activePublisher.canonicalPath,
|
|
29
|
+
localePaths: activePublisher.localePaths
|
|
30
|
+
};
|
|
31
|
+
setI18nParams(activePublisher.localeParams);
|
|
32
|
+
};
|
|
33
|
+
const useActiveContentRouteState = () => useState(CONTENT_ROUTE_STATE_KEY, () => null);
|
|
34
|
+
const normalizeRouteParams = (params) => {
|
|
35
|
+
return Object.fromEntries(
|
|
36
|
+
Object.entries(params).filter(([, value]) => value !== void 0)
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
const normalizeContentRoute = (value) => {
|
|
40
|
+
if (!value) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const stringPaths = {};
|
|
44
|
+
for (const [locale, entry] of Object.entries(value.localePaths || {})) {
|
|
45
|
+
stringPaths[locale] = typeof entry === "string" ? entry : entry.path;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
path: value.path,
|
|
49
|
+
canonicalPath: value.canonicalPath,
|
|
50
|
+
localePaths: stringPaths
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const normalizeLocalePath = (entry) => typeof entry === "string" ? entry : entry?.path;
|
|
54
|
+
const normalizeRoutePath = (path) => {
|
|
55
|
+
if (typeof path !== "string") return void 0;
|
|
56
|
+
const normalized = path.replace(/\/+$/, "");
|
|
57
|
+
return normalized || "/";
|
|
58
|
+
};
|
|
59
|
+
const contentRouteMatches = (contentRoute, path) => {
|
|
60
|
+
const normalizedPath = normalizeRoutePath(path);
|
|
61
|
+
return normalizeRoutePath(contentRoute.path) === normalizedPath || normalizeRoutePath(contentRoute.canonicalPath) === normalizedPath || Object.values(contentRoute.localePaths).some((localePath) => normalizeRoutePath(localePath) === normalizedPath);
|
|
62
|
+
};
|
|
63
|
+
const resolveLocalizedRouteParams = (page, router, route, getRouteBaseName) => {
|
|
64
|
+
if (!page) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
const baseName = getRouteBaseName(route);
|
|
68
|
+
return Object.fromEntries(
|
|
69
|
+
Object.entries(page.localePaths || {}).map(([locale, entry]) => {
|
|
70
|
+
const path = normalizeLocalePath(entry);
|
|
71
|
+
if (!path) {
|
|
72
|
+
return [locale, {}];
|
|
73
|
+
}
|
|
74
|
+
const resolvedRoute = router.resolve(path);
|
|
75
|
+
const resolvedBaseName = getRouteBaseName(resolvedRoute);
|
|
76
|
+
if (baseName && resolvedBaseName && resolvedBaseName !== baseName) {
|
|
77
|
+
return [locale, {}];
|
|
78
|
+
}
|
|
79
|
+
return [locale, normalizeRouteParams(resolvedRoute.params)];
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
export function useContentSwitchLocalePath() {
|
|
84
|
+
const route = useRoute();
|
|
85
|
+
const switchLocalePath = useSwitchLocalePath();
|
|
86
|
+
const activeContentRoute = useActiveContentRouteState();
|
|
87
|
+
return (locale) => {
|
|
88
|
+
const active = activeContentRoute.value;
|
|
89
|
+
const contentRoute = active && contentRouteMatches(active, route.path) ? active : getRouteMetaState(route.meta);
|
|
90
|
+
return contentRoute?.localePaths[locale] || switchLocalePath(locale);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export function useContentRoute(value) {
|
|
94
|
+
const route = useRoute();
|
|
95
|
+
const router = useRouter();
|
|
96
|
+
const getRouteBaseName = useRouteBaseName();
|
|
97
|
+
const setI18nParams = useSetI18nParams();
|
|
98
|
+
const activeContentRouteState = useActiveContentRouteState();
|
|
99
|
+
const token = `content-route:${++contentRouteTokenId}`;
|
|
100
|
+
const order = contentRouteTokenId;
|
|
101
|
+
const activeContentRoute = computed(() => {
|
|
102
|
+
const contentRoute = normalizeContentRoute(toValue(value));
|
|
103
|
+
if (!contentRoute || !contentRouteMatches(contentRoute, route.path)) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
...contentRoute,
|
|
108
|
+
token
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
const localeParams = computed(() => {
|
|
112
|
+
const contentRoute = toValue(value);
|
|
113
|
+
const normalizedContentRoute = normalizeContentRoute(contentRoute);
|
|
114
|
+
if (!normalizedContentRoute || !contentRouteMatches(normalizedContentRoute, route.path)) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
return resolveLocalizedRouteParams(contentRoute, router, route, getRouteBaseName);
|
|
118
|
+
});
|
|
119
|
+
watch([activeContentRoute, localeParams], ([contentRoute, params]) => {
|
|
120
|
+
const meta = router.currentRoute.value.meta;
|
|
121
|
+
const registry = getRoutePublisherRegistry(meta) || {};
|
|
122
|
+
if (contentRoute) {
|
|
123
|
+
registry[token] = {
|
|
124
|
+
...contentRoute,
|
|
125
|
+
localeParams: params,
|
|
126
|
+
order
|
|
127
|
+
};
|
|
128
|
+
meta[CONTENT_ROUTE_REGISTRY_KEY] = registry;
|
|
129
|
+
} else {
|
|
130
|
+
Reflect.deleteProperty(registry, token);
|
|
131
|
+
}
|
|
132
|
+
syncPublishedContentRoute(meta, setI18nParams);
|
|
133
|
+
activeContentRouteState.value = getRouteMetaState(meta) ?? null;
|
|
134
|
+
}, { immediate: true, flush: "sync" });
|
|
135
|
+
onScopeDispose(() => {
|
|
136
|
+
const meta = router.currentRoute.value.meta;
|
|
137
|
+
const registry = getRoutePublisherRegistry(meta);
|
|
138
|
+
if (registry) {
|
|
139
|
+
Reflect.deleteProperty(registry, token);
|
|
140
|
+
}
|
|
141
|
+
syncPublishedContentRoute(meta, setI18nParams);
|
|
142
|
+
activeContentRouteState.value = getRouteMetaState(meta) ?? null;
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
switchLocalePath: useContentSwitchLocalePath(),
|
|
146
|
+
localePaths: computed(() => activeContentRoute.value?.localePaths || {}),
|
|
147
|
+
canonicalPath: computed(() => activeContentRoute.value?.canonicalPath),
|
|
148
|
+
path: computed(() => activeContentRoute.value?.path)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search.js'
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
3
|
+
import { ref } from '#imports';
|
|
4
|
+
import type { ContentCollectionMap } from '@lupinum/ginko-content';
|
|
5
|
+
import type { ContentNavigationItem } from '../../../types/content';
|
|
6
|
+
import type { ContentSearchSection } from '../../../types/query';
|
|
7
|
+
import type { ContentSearchResult } from '../../../types/search';
|
|
8
|
+
export interface UseContentSearchResultsOptions {
|
|
9
|
+
locale?: MaybeRefOrGetter<string | undefined>;
|
|
10
|
+
}
|
|
11
|
+
export interface UseContentSearchOptions extends UseContentSearchResultsOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Initial search term for the controlled query ref.
|
|
14
|
+
*/
|
|
15
|
+
initialQuery?: MaybeRefOrGetter<string | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of results exposed by the headless controller.
|
|
18
|
+
*/
|
|
19
|
+
limit?: MaybeRefOrGetter<number | undefined>;
|
|
20
|
+
}
|
|
21
|
+
export interface UseContentSearchResultsResult {
|
|
22
|
+
results: ComputedRef<ContentSearchResult[]>;
|
|
23
|
+
pending: ComputedRef<boolean>;
|
|
24
|
+
error: ComputedRef<unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface UseContentSearchResult extends UseContentSearchResultsResult {
|
|
27
|
+
query: Ref<string>;
|
|
28
|
+
activeIndex: Ref<number>;
|
|
29
|
+
activeResult: ComputedRef<ContentSearchResult | null>;
|
|
30
|
+
hasQuery: ComputedRef<boolean>;
|
|
31
|
+
hasResults: ComputedRef<boolean>;
|
|
32
|
+
isEmpty: ComputedRef<boolean>;
|
|
33
|
+
setQuery: (value: string) => void;
|
|
34
|
+
setActiveIndex: (index: number) => void;
|
|
35
|
+
next: () => void;
|
|
36
|
+
previous: () => void;
|
|
37
|
+
reset: () => void;
|
|
38
|
+
select: (index?: number) => ContentSearchResult | null;
|
|
39
|
+
}
|
|
40
|
+
export interface UseContentSearchDataOptions {
|
|
41
|
+
locale?: MaybeRefOrGetter<string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
export interface UseContentSearchDataResult {
|
|
44
|
+
files: ComputedRef<ContentSearchSection[]>;
|
|
45
|
+
searchNavigation: ComputedRef<ContentNavigationItem[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Compatibility alias for `searchNavigation`.
|
|
48
|
+
*
|
|
49
|
+
* Prefer `searchNavigation` so layout navigation and search navigation are
|
|
50
|
+
* not confused.
|
|
51
|
+
*/
|
|
52
|
+
navigation: ComputedRef<ContentNavigationItem[]>;
|
|
53
|
+
searchTerm: ReturnType<typeof ref<string>>;
|
|
54
|
+
}
|
|
55
|
+
export declare function useContentSearchData<K extends keyof ContentCollectionMap & string>(collection: K, options?: UseContentSearchDataOptions): Promise<UseContentSearchDataResult>;
|
|
56
|
+
export declare function useContentSearchData(collection: string, options?: UseContentSearchDataOptions): Promise<UseContentSearchDataResult>;
|
|
57
|
+
export declare const useContentSearchResults: (search: MaybeRefOrGetter<string>, options?: UseContentSearchResultsOptions) => Promise<UseContentSearchResultsResult>;
|
|
58
|
+
export declare const useContentSearch: (options?: UseContentSearchOptions) => Promise<UseContentSearchResult>;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { computed, ref, shallowRef, toValue, useAsyncData, useFetch, useRuntimeConfig, watchEffect } from "#imports";
|
|
2
|
+
import { withBase } from "ufo";
|
|
3
|
+
import { searchRecords } from "../../shared/search.js";
|
|
4
|
+
import { createContentSearchNavigation } from "../../../features/search/navigation";
|
|
5
|
+
import { resolveCollectionSearchSectionsData } from "../../../features/collections/resolve";
|
|
6
|
+
import { resolveCollectionI18n } from "../../../features/localization/path";
|
|
7
|
+
import { many, tree } from "./query-api.js";
|
|
8
|
+
import { resolveActiveLocale } from "./locale.js";
|
|
9
|
+
import { getContentRuntime } from "./runtime.js";
|
|
10
|
+
const defaultSearchConfig = {
|
|
11
|
+
apiBaseURL: "/api/_content/search",
|
|
12
|
+
indexURL: "/api/_content/search/index.json",
|
|
13
|
+
engine: "minisearch",
|
|
14
|
+
minisearch: {
|
|
15
|
+
fields: ["title", "content", "headings"],
|
|
16
|
+
storeFields: ["path", "title", "excerpt", "anchor", "locale"],
|
|
17
|
+
boost: {
|
|
18
|
+
title: 4,
|
|
19
|
+
headings: 2,
|
|
20
|
+
content: 1
|
|
21
|
+
},
|
|
22
|
+
fuzzy: 0.2,
|
|
23
|
+
prefix: true
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const disabledSearchError = new Error("Ginko search is disabled. Enable it with `content.search`.");
|
|
27
|
+
const isRecord = (value) => {
|
|
28
|
+
return value !== null && typeof value === "object";
|
|
29
|
+
};
|
|
30
|
+
const resolveSearchConfig = (runtimeConfig) => {
|
|
31
|
+
const contentValue = runtimeConfig.public.content;
|
|
32
|
+
if (!isRecord(contentValue)) {
|
|
33
|
+
return defaultSearchConfig;
|
|
34
|
+
}
|
|
35
|
+
const value = contentValue.search;
|
|
36
|
+
if (value === false) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!isRecord(value)) {
|
|
40
|
+
return defaultSearchConfig;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
apiBaseURL: typeof value.apiBaseURL === "string" ? value.apiBaseURL : defaultSearchConfig.apiBaseURL,
|
|
44
|
+
indexURL: typeof value.indexURL === "string" ? value.indexURL : defaultSearchConfig.indexURL,
|
|
45
|
+
engine: value.engine === "pagefind" || value.engine === "cms" ? value.engine : "minisearch",
|
|
46
|
+
minisearch: resolveMiniSearchRuntimeOptions(value.minisearch)
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const resolveMiniSearchRuntimeOptions = (value) => {
|
|
50
|
+
if (!isRecord(value)) {
|
|
51
|
+
return defaultSearchConfig.minisearch;
|
|
52
|
+
}
|
|
53
|
+
const fields = Array.isArray(value.fields) ? value.fields.filter((field) => typeof field === "string" && field.length > 0) : [];
|
|
54
|
+
const storeFields = Array.isArray(value.storeFields) ? value.storeFields.filter((field) => typeof field === "string" && field.length > 0) : [];
|
|
55
|
+
const boost = isRecord(value.boost) ? Object.fromEntries(Object.entries(value.boost).filter((entry) => typeof entry[1] === "number" && Number.isFinite(entry[1]))) : {};
|
|
56
|
+
return {
|
|
57
|
+
fields: fields.length ? fields : defaultSearchConfig.minisearch.fields,
|
|
58
|
+
storeFields: storeFields.length ? storeFields : defaultSearchConfig.minisearch.storeFields,
|
|
59
|
+
boost: Object.keys(boost).length ? boost : defaultSearchConfig.minisearch.boost,
|
|
60
|
+
fuzzy: typeof value.fuzzy === "boolean" || typeof value.fuzzy === "number" ? value.fuzzy : defaultSearchConfig.minisearch.fuzzy,
|
|
61
|
+
prefix: typeof value.prefix === "boolean" ? value.prefix : defaultSearchConfig.minisearch.prefix
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const resolveContentConfig = (runtimeConfig) => {
|
|
65
|
+
const value = runtimeConfig.public.content;
|
|
66
|
+
if (!isRecord(value)) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
locales: Array.isArray(value.locales) ? value.locales.filter((locale) => typeof locale === "string") : void 0,
|
|
71
|
+
search: value.search === false ? false : isRecord(value.search) ? {
|
|
72
|
+
apiBaseURL: typeof value.search.apiBaseURL === "string" ? value.search.apiBaseURL : defaultSearchConfig.apiBaseURL,
|
|
73
|
+
indexURL: typeof value.search.indexURL === "string" ? value.search.indexURL : defaultSearchConfig.indexURL,
|
|
74
|
+
engine: value.search.engine === "pagefind" || value.search.engine === "cms" ? value.search.engine : "minisearch",
|
|
75
|
+
minisearch: resolveMiniSearchRuntimeOptions(value.search.minisearch)
|
|
76
|
+
} : void 0
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const resolveAppConfig = (runtimeConfig) => {
|
|
80
|
+
const value = runtimeConfig.app;
|
|
81
|
+
return value || {};
|
|
82
|
+
};
|
|
83
|
+
const loadSearchSections = async (collection, options) => {
|
|
84
|
+
const runtime = getContentRuntime();
|
|
85
|
+
const { locales, defaultLocale } = resolveCollectionI18n(collection, runtime);
|
|
86
|
+
const locale = toValue(options.locale);
|
|
87
|
+
return await resolveCollectionSearchSectionsData(collection, runtime, {
|
|
88
|
+
locale,
|
|
89
|
+
activeLocale: locale || resolveActiveLocale(locales, defaultLocale),
|
|
90
|
+
loadPages: async (extraFields) => {
|
|
91
|
+
return await many(collection, {
|
|
92
|
+
...locale ? { locale } : {},
|
|
93
|
+
select: ["_path", "title", "description", "body", ...extraFields]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export async function useContentSearchData(collection, options = {}) {
|
|
99
|
+
const searchTerm = ref("");
|
|
100
|
+
const locale = computed(() => toValue(options.locale));
|
|
101
|
+
const payload = await useAsyncData(computed(() => `content-search-data:${collection}:${locale.value || "default"}`), async () => {
|
|
102
|
+
const locale2 = toValue(options.locale);
|
|
103
|
+
const [navigation, files2] = await Promise.all([
|
|
104
|
+
tree(collection, locale2 ? { locale: locale2 } : {}),
|
|
105
|
+
loadSearchSections(collection, options)
|
|
106
|
+
]);
|
|
107
|
+
return {
|
|
108
|
+
files: files2,
|
|
109
|
+
navigation: createContentSearchNavigation(navigation)
|
|
110
|
+
};
|
|
111
|
+
}, {
|
|
112
|
+
watch: [locale]
|
|
113
|
+
});
|
|
114
|
+
const files = computed(() => payload.data.value?.files || []);
|
|
115
|
+
const searchNavigation = computed(() => payload.data.value?.navigation || []);
|
|
116
|
+
return {
|
|
117
|
+
files,
|
|
118
|
+
searchNavigation,
|
|
119
|
+
navigation: searchNavigation,
|
|
120
|
+
searchTerm
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export const useContentSearchResults = async (search, options = {}) => {
|
|
124
|
+
const runtimeConfig = useRuntimeConfig();
|
|
125
|
+
const config = resolveSearchConfig(runtimeConfig);
|
|
126
|
+
const appConfig = resolveAppConfig(runtimeConfig);
|
|
127
|
+
if (config === false) {
|
|
128
|
+
return {
|
|
129
|
+
results: computed(() => []),
|
|
130
|
+
pending: computed(() => false),
|
|
131
|
+
error: computed(() => disabledSearchError)
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (config.engine === "pagefind") {
|
|
135
|
+
return usePagefindSearch(search, withBase("/pagefind/pagefind.js", appConfig.baseURL || "/"), options);
|
|
136
|
+
}
|
|
137
|
+
if (config.engine === "cms") {
|
|
138
|
+
return await useCmsSearch(search, config.apiBaseURL, options);
|
|
139
|
+
}
|
|
140
|
+
return await useMiniSearch(search, config.indexURL, config.minisearch, options);
|
|
141
|
+
};
|
|
142
|
+
export const useContentSearch = async (options = {}) => {
|
|
143
|
+
const query = ref(String(toValue(options.initialQuery) || ""));
|
|
144
|
+
const activeIndex = ref(-1);
|
|
145
|
+
const search = await useContentSearchResults(query, options);
|
|
146
|
+
const limit = computed(() => {
|
|
147
|
+
const value = toValue(options.limit);
|
|
148
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
149
|
+
});
|
|
150
|
+
const results = computed(() => {
|
|
151
|
+
const items = search.results.value;
|
|
152
|
+
return typeof limit.value === "number" ? items.slice(0, limit.value) : items;
|
|
153
|
+
});
|
|
154
|
+
const hasQuery = computed(() => query.value.trim().length > 0);
|
|
155
|
+
const hasResults = computed(() => results.value.length > 0);
|
|
156
|
+
const isEmpty = computed(() => hasQuery.value && !search.pending.value && !search.error.value && !results.value.length);
|
|
157
|
+
const activeResult = computed(() => results.value[activeIndex.value] || null);
|
|
158
|
+
let lastQuery = query.value;
|
|
159
|
+
const setActiveIndex = (index) => {
|
|
160
|
+
const lastIndex = results.value.length - 1;
|
|
161
|
+
if (!Number.isFinite(index)) {
|
|
162
|
+
activeIndex.value = -1;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
activeIndex.value = lastIndex < 0 ? -1 : Math.max(-1, Math.min(Math.floor(index), lastIndex));
|
|
166
|
+
};
|
|
167
|
+
const setQuery = (value) => {
|
|
168
|
+
query.value = value;
|
|
169
|
+
setActiveIndex(-1);
|
|
170
|
+
};
|
|
171
|
+
const next = () => setActiveIndex(activeIndex.value + 1);
|
|
172
|
+
const previous = () => setActiveIndex(activeIndex.value <= -1 ? -1 : activeIndex.value - 1);
|
|
173
|
+
const reset = () => {
|
|
174
|
+
query.value = "";
|
|
175
|
+
activeIndex.value = -1;
|
|
176
|
+
};
|
|
177
|
+
const select = (index = activeIndex.value) => results.value[index] || null;
|
|
178
|
+
watchEffect(() => {
|
|
179
|
+
const currentQuery = query.value;
|
|
180
|
+
const resultCount = results.value.length;
|
|
181
|
+
if (currentQuery !== lastQuery) {
|
|
182
|
+
lastQuery = currentQuery;
|
|
183
|
+
activeIndex.value = -1;
|
|
184
|
+
}
|
|
185
|
+
if (!Number.isInteger(activeIndex.value) || activeIndex.value < -1) {
|
|
186
|
+
activeIndex.value = -1;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!resultCount) {
|
|
190
|
+
activeIndex.value = -1;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (activeIndex.value >= resultCount) {
|
|
194
|
+
activeIndex.value = resultCount - 1;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
query,
|
|
199
|
+
results,
|
|
200
|
+
pending: search.pending,
|
|
201
|
+
error: search.error,
|
|
202
|
+
activeIndex,
|
|
203
|
+
activeResult,
|
|
204
|
+
hasQuery,
|
|
205
|
+
hasResults,
|
|
206
|
+
isEmpty,
|
|
207
|
+
setQuery,
|
|
208
|
+
setActiveIndex,
|
|
209
|
+
next,
|
|
210
|
+
previous,
|
|
211
|
+
reset,
|
|
212
|
+
select
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
const useMiniSearch = async (search, indexURL, minisearch, options) => {
|
|
216
|
+
const locale = computed(() => toValue(options.locale));
|
|
217
|
+
const requestUrl = computed(() => locale.value ? `${indexURL}?locale=${encodeURIComponent(locale.value)}` : indexURL);
|
|
218
|
+
const { data, pending, error } = await useFetch(requestUrl);
|
|
219
|
+
const results = computed(() => searchRecords(data.value || [], toValue(search), locale.value, minisearch));
|
|
220
|
+
return {
|
|
221
|
+
results,
|
|
222
|
+
pending: computed(() => pending.value),
|
|
223
|
+
error: computed(() => error.value)
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
const useCmsSearch = async (search, apiBaseURL, options) => {
|
|
227
|
+
const locale = computed(() => toValue(options.locale));
|
|
228
|
+
const requestUrl = computed(() => {
|
|
229
|
+
const params = new URLSearchParams();
|
|
230
|
+
const term = String(toValue(search) || "");
|
|
231
|
+
if (term) {
|
|
232
|
+
params.set("q", term);
|
|
233
|
+
}
|
|
234
|
+
if (locale.value) {
|
|
235
|
+
params.set("locale", locale.value);
|
|
236
|
+
}
|
|
237
|
+
const query = params.toString();
|
|
238
|
+
return query ? `${apiBaseURL}?${query}` : apiBaseURL;
|
|
239
|
+
});
|
|
240
|
+
const { data, pending, error } = await useFetch(requestUrl);
|
|
241
|
+
return {
|
|
242
|
+
results: computed(() => data.value || []),
|
|
243
|
+
pending: computed(() => pending.value),
|
|
244
|
+
error: computed(() => error.value)
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
let pagefindModulePromise = null;
|
|
248
|
+
const loadPagefindModule = (pagefindUrl) => {
|
|
249
|
+
pagefindModulePromise = pagefindModulePromise || import(
|
|
250
|
+
/* @vite-ignore */
|
|
251
|
+
pagefindUrl
|
|
252
|
+
);
|
|
253
|
+
return pagefindModulePromise;
|
|
254
|
+
};
|
|
255
|
+
const deriveLocale = (path, locales = []) => {
|
|
256
|
+
const segments = path.split("/").filter(Boolean);
|
|
257
|
+
return segments[0] && locales.includes(segments[0]) ? segments[0] : void 0;
|
|
258
|
+
};
|
|
259
|
+
const usePagefindSearch = (search, pagefindUrl, options) => {
|
|
260
|
+
const runtimeConfig = useRuntimeConfig();
|
|
261
|
+
const contentConfig = resolveContentConfig(runtimeConfig);
|
|
262
|
+
const locale = computed(() => toValue(options.locale));
|
|
263
|
+
const results = ref([]);
|
|
264
|
+
const pending = ref(false);
|
|
265
|
+
const error = shallowRef(null);
|
|
266
|
+
if (contentConfig?.search === false) {
|
|
267
|
+
return {
|
|
268
|
+
results: computed(() => []),
|
|
269
|
+
pending: computed(() => false),
|
|
270
|
+
error: computed(() => disabledSearchError)
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
watchEffect(async (onCleanup) => {
|
|
274
|
+
const term = toValue(search).trim();
|
|
275
|
+
let cancelled = false;
|
|
276
|
+
onCleanup(() => {
|
|
277
|
+
cancelled = true;
|
|
278
|
+
});
|
|
279
|
+
if (!term) {
|
|
280
|
+
results.value = [];
|
|
281
|
+
pending.value = false;
|
|
282
|
+
error.value = null;
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
pending.value = true;
|
|
286
|
+
error.value = null;
|
|
287
|
+
try {
|
|
288
|
+
const pagefind = await loadPagefindModule(pagefindUrl);
|
|
289
|
+
const response = await pagefind.search(term);
|
|
290
|
+
const normalized = await Promise.all((response?.results || []).map(async (result) => {
|
|
291
|
+
const data = await result.data();
|
|
292
|
+
const [path = "", anchor] = String(data?.url || "").split("#");
|
|
293
|
+
return {
|
|
294
|
+
path,
|
|
295
|
+
title: data?.meta?.title || path,
|
|
296
|
+
excerpt: data?.excerpt || "",
|
|
297
|
+
score: result.score,
|
|
298
|
+
anchor: anchor || void 0,
|
|
299
|
+
locale: data?.meta?.locale || deriveLocale(path, contentConfig?.locales || [])
|
|
300
|
+
};
|
|
301
|
+
}));
|
|
302
|
+
if (!cancelled) {
|
|
303
|
+
results.value = locale.value ? normalized.filter((result) => result.locale === locale.value) : normalized;
|
|
304
|
+
}
|
|
305
|
+
} catch (err) {
|
|
306
|
+
if (!cancelled) {
|
|
307
|
+
error.value = err;
|
|
308
|
+
results.value = [];
|
|
309
|
+
}
|
|
310
|
+
} finally {
|
|
311
|
+
if (!cancelled) {
|
|
312
|
+
pending.value = false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
return {
|
|
317
|
+
results: computed(() => results.value),
|
|
318
|
+
pending: computed(() => pending.value),
|
|
319
|
+
error: computed(() => error.value)
|
|
320
|
+
};
|
|
321
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './site-data.js'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ContentApiFetcher } from './utils';
|
|
2
|
+
export interface QuerySiteDataOptions {
|
|
3
|
+
locale?: string;
|
|
4
|
+
fetcher?: ContentApiFetcher;
|
|
5
|
+
}
|
|
6
|
+
export interface ContentSiteDataResponse<T = unknown> {
|
|
7
|
+
key?: string;
|
|
8
|
+
locale?: string;
|
|
9
|
+
data?: T | null;
|
|
10
|
+
updatedAt?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function querySiteData<T = unknown>(key: string, options?: QuerySiteDataOptions): Promise<ContentSiteDataResponse<T>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { withQuery } from "ufo";
|
|
2
|
+
import { withContentBase, getContentApiFetcher } from "./utils.js";
|
|
3
|
+
export async function querySiteData(key, options = {}) {
|
|
4
|
+
const fetcher = getContentApiFetcher(options.fetcher);
|
|
5
|
+
return await fetcher(withContentBase(withQuery("/site-data", {
|
|
6
|
+
key,
|
|
7
|
+
...options.locale ? { locale: options.locale } : {}
|
|
8
|
+
})), {
|
|
9
|
+
method: "GET",
|
|
10
|
+
responseType: "json"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './toc.js'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { Toc, TocLink } from '../../../types/content';
|
|
3
|
+
export type { Toc, TocLink };
|
|
4
|
+
export interface ContentTocOptions {
|
|
5
|
+
depth?: number;
|
|
6
|
+
title?: string;
|
|
7
|
+
searchDepth?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function extractContentToc(content: string, options?: ContentTocOptions): Toc;
|
|
10
|
+
export declare function useContentToc(content: Ref<string | null | undefined>, options?: ContentTocOptions): Ref<TocLink[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
function slugHeading(value) {
|
|
3
|
+
return value.toLowerCase().replace(/[^\w\s-]/g, "").trim().replace(/\s+/g, "-");
|
|
4
|
+
}
|
|
5
|
+
export function extractContentToc(content, options = {}) {
|
|
6
|
+
const maxDepth = options.depth ?? 4;
|
|
7
|
+
const links = [];
|
|
8
|
+
const headingRegex = /^(#{2,4})\s+(\S.*)$/gm;
|
|
9
|
+
let match = headingRegex.exec(content);
|
|
10
|
+
while (match !== null) {
|
|
11
|
+
const depth = match[1].length;
|
|
12
|
+
const text = match[2].trim();
|
|
13
|
+
if (depth <= maxDepth) {
|
|
14
|
+
links.push({ id: slugHeading(text), text, depth });
|
|
15
|
+
}
|
|
16
|
+
match = headingRegex.exec(content);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
title: options.title ?? "",
|
|
20
|
+
depth: 2,
|
|
21
|
+
searchDepth: options.searchDepth ?? maxDepth,
|
|
22
|
+
links
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function useContentToc(content, options = {}) {
|
|
26
|
+
return computed(() => {
|
|
27
|
+
const raw = content.value;
|
|
28
|
+
if (!raw) return [];
|
|
29
|
+
return extractContentToc(raw, options).links;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-content.js'
|