import { defineComponent, useSlots, h, useSSRContext, unref, watch } from 'vue'; import { h as useRoute, a as useHead, u as useRuntimeConfig } from '../server.mjs'; import { withTrailingSlash, joinURL, withoutTrailingSlash, hasProtocol } from 'ufo'; import _sfc_main$2 from './ContentRenderer-aa0632eb.mjs'; import _sfc_main$1 from './ContentQuery-c9561d42.mjs'; import 'ofetch'; import 'hookable'; import 'unctx'; import 'h3'; import '@unhead/ssr'; import 'unhead'; import '@unhead/shared'; import 'vue-router'; import '@intlify/core-base'; import 'cookie-es'; import 'is-https'; import 'anu-vue'; import 'vue/server-renderer'; import 'defu'; import '../../nitro/node-server.mjs'; import 'node-fetch-native/polyfill'; import 'node:http'; import 'node:https'; import 'destr'; import 'unenv/runtime/fetch/index'; import 'scule'; import 'klona'; import 'ohash'; import 'unstorage'; import 'unstorage/drivers/fs'; import 'unstorage/drivers/overlay'; import 'unstorage/drivers/memory'; import 'radix3'; import 'node:fs'; import 'node:url'; import 'pathe'; import '@intlify/bundle-utils'; import 'unified'; import 'mdast-util-to-string'; import 'micromark/lib/preprocess.js'; import 'micromark/lib/postprocess.js'; import 'unist-util-stringify-position'; import 'micromark-util-character'; import 'micromark-util-chunked'; import 'micromark-util-resolve-all'; import 'remark-emoji'; import 'rehype-slug'; import 'remark-squeeze-paragraphs'; import 'rehype-external-links'; import 'remark-gfm'; import 'rehype-sort-attribute-values'; import 'rehype-sort-attributes'; import 'rehype-raw'; import 'remark-mdc'; import 'remark-parse'; import 'remark-rehype'; import 'mdast-util-to-hast'; import 'detab'; import 'unist-builder'; import 'mdurl'; import 'slugify'; import 'unist-util-position'; import 'unist-util-visit'; import 'shiki-es'; import 'unenv/runtime/npm/consola'; import './ContentRendererMarkdown-6936f2dc.mjs'; import 'property-information'; import './preview-38d6e135.mjs'; import './asyncData-e8a8bfb6.mjs'; import './query-e0164f92.mjs'; import './utils-6d756e03.mjs'; const useContentHead = (_content, to = useRoute()) => { const content = unref(_content); const config = /* @__PURE__ */ useRuntimeConfig(); const refreshHead = (data = content) => { if (!to.path || !data) { return; } const head = Object.assign({}, (data == null ? void 0 : data.head) || {}); head.meta = [...head.meta || []]; head.link = [...head.link || []]; const title = head.title || (data == null ? void 0 : data.title); if (title) { head.title = title; if (!head.meta.some((m) => m.property === "og:title")) { head.meta.push({ property: "og:title", content: title }); } } const host = config.public.content.host; if (host) { const _url = joinURL(host ?? "/", config.app.baseURL, to.fullPath); const url = config.public.content.trailingSlash ? withTrailingSlash(_url) : withoutTrailingSlash(_url); if (!head.meta.some((m) => m.property === "og:url")) { head.meta.push({ property: "og:url", content: url }); } if (!head.link.some((m) => m.rel === "canonical")) { head.link.push({ rel: "canonical", href: url }); } } const description = (head == null ? void 0 : head.description) || (data == null ? void 0 : data.description); if (description && head.meta.filter((m) => m.name === "description").length === 0) { head.meta.push({ name: "description", content: description }); } if (description && !head.meta.some((m) => m.property === "og:description")) { head.meta.push({ property: "og:description", content: description }); } const image = (head == null ? void 0 : head.image) || (data == null ? void 0 : data.image); if (image && head.meta.filter((m) => m.property === "og:image").length === 0) { if (typeof image === "string") { head.meta.push({ property: "og:image", // @ts-ignore - We expect `head.image` from Nuxt configurations... content: host && !hasProtocol(image) ? new URL(joinURL(config.app.baseURL, image), host).href : image }); } if (typeof image === "object") { const imageKeys = [ "src", "secure_url", "type", "width", "height", "alt" ]; for (const key of imageKeys) { if (key === "src" && image.src) { const isAbsoluteURL = hasProtocol(image.src); const imageURL = isAbsoluteURL ? image.src : joinURL(config.app.baseURL, image.src ?? "/"); head.meta.push({ property: "og:image", content: host && !isAbsoluteURL ? new URL(imageURL, host).href : imageURL }); } else if (image[key]) { head.meta.push({ property: `og:image:${key}`, content: image[key] }); } } } } { useHead(head); } }; watch(() => unref(_content), refreshHead, { immediate: true }); }; const _sfc_main = /* @__PURE__ */ defineComponent({ name: "ContentDoc", props: { /** * Renderer props */ /** * The tag to use for the renderer element if it is used. * @default 'div' */ tag: { type: String, required: false, default: "div" }, /** * Whether or not to render the excerpt. * @default false */ excerpt: { type: Boolean, default: false }, /** * Query props */ /** * The path of the content to load from content source. * @default useRoute().path */ path: { type: String, required: false, default: void 0 }, /** * A query builder params object to be passed to component. */ query: { type: Object, required: false, default: void 0 }, /** * Whether or not to map the document data to the `head` property. */ head: { type: Boolean, required: false, default: true } }, /** * Document empty fallback * @slot empty */ /** * Document not found fallback * @slot not-found */ render(ctx) { const slots = useSlots(); const { tag, excerpt, path, query, head } = ctx; const contentQueryProps = { ...query || {}, path: path || (query == null ? void 0 : query.path) || withTrailingSlash(useRoute().path), find: "one" }; const emptyNode = (slot, data) => h("pre", null, JSON.stringify({ message: "You should use slots with ", slot, data }, null, 2)); return h( _sfc_main$1, contentQueryProps, { // Default slot default: (slots == null ? void 0 : slots.default) ? ({ data, refresh, isPartial }) => { var _a; if (head) { useContentHead(data); } return (_a = slots.default) == null ? void 0 : _a.call(slots, { doc: data, refresh, isPartial, excerpt, ...this.$attrs }); } : ({ data }) => { if (head) { useContentHead(data); } return h( _sfc_main$2, { value: data, excerpt, tag, ...this.$attrs }, // Forward local `empty` slots to ContentRenderer if it is used. { empty: (bindings) => (slots == null ? void 0 : slots.empty) ? slots.empty(bindings) : emptyNode("default", data) } ); }, // Empty slot empty: (bindings) => { var _a; return ((_a = slots == null ? void 0 : slots.empty) == null ? void 0 : _a.call(slots, bindings)) || h("p", null, "Document is empty, overwrite this content with #empty slot in ."); }, // Not Found slot "not-found": (bindings) => { var _a; return ((_a = slots == null ? void 0 : slots["not-found"]) == null ? void 0 : _a.call(slots, bindings)) || h("p", null, "Document not found, overwrite this content with #not-found slot in ."); } } ); } }); const _sfc_setup = _sfc_main.setup; _sfc_main.setup = (props, ctx) => { const ssrContext = useSSRContext(); (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("node_modules/.pnpm/@nuxt+content@2.6.0_rollup@2.79.1/node_modules/@nuxt/content/dist/runtime/components/ContentDoc.vue"); return _sfc_setup ? _sfc_setup(props, ctx) : void 0; }; export { _sfc_main as default }; //# sourceMappingURL=ContentDoc-b44cd75e.mjs.map