@onderwijsin/nuxt-markdown-renderer 0.4.0 → 0.5.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/README.md CHANGED
@@ -59,11 +59,87 @@ Import the module stylesheet in the consuming application's main CSS file after
59
59
  </template>
60
60
  ```
61
61
 
62
- | Prop | Type | Default | Description |
63
- | -------------- | ---------------- | ----------- | ----------------------------------------------- |
64
- | `value` | `string` | `undefined` | Markdown or MDC source. |
65
- | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
66
- | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
62
+ | Prop | Type | Default | Description |
63
+ | -------------- | ---------------- | ----------- | --------------------------------------------------------------- |
64
+ | `value` | `string` | `undefined` | Markdown or MDC source. |
65
+ | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
66
+ | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
67
+ | `server` | `boolean` | `false` | Render static HTML inside a host `.server.vue` component. |
68
+ | `hydrate` | `string[]` | `undefined` | Registered block MDC component names to hydrate in server mode. |
69
+
70
+ ### Static Markdown and MDC in a server island
71
+
72
+ Enable Nuxt component islands and use `server` inside a host-owned `.server.vue` component with a
73
+ single root element. Use `componentIslands: true` for static HTML. To hydrate selected MDC blocks
74
+ with Nuxt's Vite builder, use `selectiveClient: "deep"`, as in this example with
75
+ `app/components/renderer/MarkdownCounter.vue`.
76
+ [Nuxt server components](https://nuxt.com/docs/4.x/guide/concepts/server-components)
77
+
78
+ ```ts
79
+ // nuxt.config.ts
80
+ export default defineNuxtConfig({
81
+ modules: ["@onderwijsin/nuxt-markdown-renderer"],
82
+ experimental: { componentIslands: { selectiveClient: "deep" } },
83
+ markdownRenderer: { componentSets: { article: ["MarkdownCounter", "MarkdownCallout"] } }
84
+ });
85
+ ```
86
+
87
+ ```vue
88
+ <!-- app/components/ArticleBody.server.vue -->
89
+ <script setup lang="ts">
90
+ import plugins from "~/markdown/plugins";
91
+
92
+ const { documentKey } = defineProps<{ documentKey: string }>();
93
+ const body = await useRequestFetch()<string>(
94
+ `/api/articles/${encodeURIComponent(documentKey)}/body`
95
+ );
96
+ </script>
97
+
98
+ <template>
99
+ <article>
100
+ <MarkdownRenderer
101
+ server
102
+ :value="body"
103
+ component-set="article"
104
+ :plugins="plugins"
105
+ :hydrate="['MarkdownCounter']"
106
+ />
107
+ </article>
108
+ </template>
109
+ ```
110
+
111
+ ```vue
112
+ <!-- app/pages/articles/[documentKey].vue -->
113
+ <script setup lang="ts">
114
+ const route = useRoute();
115
+ const documentKey = computed(() => String(route.params.documentKey));
116
+ </script>
117
+
118
+ <template>
119
+ <ArticleBody :document-key="documentKey" />
120
+ </template>
121
+ ```
122
+
123
+ Implement the example endpoint in the host app and return the document as Markdown text. The
124
+ `~/markdown/plugins` file default-exports the host's initialized Comark plugins. Omit the import and
125
+ `:plugins` binding to use the built-in plugins. Pass only a short public key to the host island
126
+ because Nuxt puts its props in the GET URL. Load the Markdown and initialize plugins, including
127
+ syntax highlighting, inside the island.
128
+
129
+ `hydrate` applies to registered MDC components allowed by the current set. Use selected components
130
+ as top-level blocks within the document. A component used inline or inside another block stays
131
+ static for that document. The renderer preserves default and named slots as server-rendered HTML.
132
+ Plain Markdown links remain anchors. Nuxt's island link navigation handles internal route links.
133
+
134
+ For private documents, authorize each request in the host loader or endpoint. Island requests bypass
135
+ page middleware. The renderer sends `Cache-Control: private, no-store` on the island response. Set
136
+ the same header on the enclosing page and data source, and disable shared caching and prerendering
137
+ for these routes, including `/__nuxt_island/**`. Reload the app when the viewer changes to discard
138
+ cached island HTML in that browser session.
139
+
140
+ Omit `server` to use the reactive renderer, including browser-side plugin execution.
141
+
142
+ ### Built-in MDC components
67
143
 
68
144
  The built-in MDC nodes are:
69
145
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-markdown-renderer",
3
3
  "configKey": "markdownRenderer",
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -6,7 +6,7 @@ import { isRecord, isString, fromEntries, toEntries } from '@onderwijsin/nuxt-mo
6
6
  import { z } from 'zod';
7
7
  import { EditorComponentInputSchema, EditorComponentEnrichmentSchema, SPECIAL_INPUT_TAG_NAME } from '../dist/schema/editor-component-schema.js';
8
8
 
9
- const version = "0.4.0";
9
+ const version = "0.5.0";
10
10
 
11
11
  function resolveRendererNodeName(filePath) {
12
12
  const fileName = basename(filePath, extname(filePath));
@@ -33,6 +33,7 @@ function generateRendererManifest(components, componentSets) {
33
33
  ).join(",\n");
34
34
  return `import { createRendererManifest } from "#markdown-renderer/manifest-factory";
35
35
 
36
+ /** @type {Record<string, () => Promise<{ default: import("vue").Component }>>} */
36
37
  const componentLoaders = {
37
38
  ${loaders}
38
39
  };
@@ -238,8 +239,11 @@ export default createComponentMetadataHandler(
238
239
  nuxt.options.alias["#markdown-renderer/reference-resolver"] = referenceResolver;
239
240
  nuxt.options.alias["#markdown-renderer/related-item-mapper"] = options.relatedItemListConfig?.mapItem ? await resolvePath(options.relatedItemListConfig.mapItem) : resolver.resolve(runtimeDir, "app", "utils", "map-related-item");
240
241
  nuxt.options.alias["#markdown-renderer/related-item-resolver"] = options.relatedItemListConfig?.linkResolver ? await resolvePath(options.relatedItemListConfig.linkResolver) : resolver.resolve(runtimeDir, "app", "utils", "resolve-related-item-path");
242
+ const islands = nuxt.options.experimental?.componentIslands;
243
+ const selectiveHydration = typeof islands === "object" && islands.selectiveClient === "deep";
241
244
  nuxt.options.appConfig.markdownRenderer = {
242
- videoBaseUrl: options.videoBaseUrl
245
+ videoBaseUrl: options.videoBaseUrl,
246
+ ...selectiveHydration && { selectiveHydration }
243
247
  };
244
248
  transpileRuntime(nuxt, runtimeDir);
245
249
  addImports({
@@ -250,6 +254,18 @@ export default createComponentMetadataHandler(
250
254
  name: "MarkdownRenderer",
251
255
  filePath: resolver.resolve(runtimeDir, "app", "components", "MarkdownRenderer.vue")
252
256
  });
257
+ if (selectiveHydration) {
258
+ addComponent({
259
+ name: "MarkdownIslandClient",
260
+ filePath: resolver.resolve(
261
+ runtimeDir,
262
+ "app",
263
+ "components",
264
+ "islands",
265
+ "MarkdownIslandClient.vue"
266
+ )
267
+ });
268
+ }
253
269
  addComponentsDir({
254
270
  path: builtInDirectory,
255
271
  pathPrefix: false,
@@ -6,6 +6,10 @@ type __VLS_Props = {
6
6
  componentSet?: string;
7
7
  /** Optional array of plugins to enhance the Markdown rendering. */
8
8
  plugins?: ComarkPlugin[];
9
+ /** Render Markdown statically inside a host-owned Nuxt server component. */
10
+ server?: boolean;
11
+ /** Registered block MDC components to hydrate in server mode. */
12
+ hydrate?: string[];
9
13
  };
10
14
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
15
  declare const _default: typeof __VLS_export;
@@ -1,13 +1,29 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
- import { useAppConfig } from "#app";
3
+ import { useAppConfig, useNuxtApp, useResponseHeader } from "#app";
4
4
  import { resolveRendererComponent } from "#markdown-renderer/manifest";
5
5
  const props = defineProps({
6
6
  value: { type: String, required: false },
7
7
  componentSet: { type: String, required: false },
8
- plugins: { type: Array, required: false }
8
+ plugins: { type: Array, required: false },
9
+ server: { type: Boolean, required: false },
10
+ hydrate: { type: Array, required: false }
9
11
  });
10
12
  const config = useAppConfig().markdownRenderer;
13
+ if (props.server) {
14
+ if (!import.meta.server || !useNuxtApp().ssrContext?.islandContext) {
15
+ throw new Error(
16
+ "MarkdownRenderer with server enabled must be used inside a Nuxt server component."
17
+ );
18
+ }
19
+ if (props.hydrate?.length && !config.selectiveHydration) {
20
+ throw new Error(
21
+ "MarkdownRenderer hydration requires componentIslands.selectiveClient: 'deep'."
22
+ );
23
+ }
24
+ useResponseHeader("Cache-Control").value = "private, no-store";
25
+ }
26
+ const islandBody = import.meta.server && props.server ? (await import("./islands/MarkdownIslandBody.vue")).default : void 0;
11
27
  const componentsManifest = computed(
12
28
  () => (name) => resolveRendererComponent(name, props.componentSet)
13
29
  );
@@ -23,7 +39,16 @@ const lazilyExtendedPlugins = computed(() => [
23
39
  </script>
24
40
 
25
41
  <template>
42
+ <component
43
+ :is="islandBody"
44
+ v-if="islandBody"
45
+ :value="value"
46
+ :component-set="componentSet"
47
+ :plugins="lazilyExtendedPlugins"
48
+ :hydrate="hydrate"
49
+ />
26
50
  <Markdown
51
+ v-else
27
52
  :value="value"
28
53
  :components-manifest="componentsManifest"
29
54
  :plugins="lazilyExtendedPlugins"
@@ -6,6 +6,10 @@ type __VLS_Props = {
6
6
  componentSet?: string;
7
7
  /** Optional array of plugins to enhance the Markdown rendering. */
8
8
  plugins?: ComarkPlugin[];
9
+ /** Render Markdown statically inside a host-owned Nuxt server component. */
10
+ server?: boolean;
11
+ /** Registered block MDC components to hydrate in server mode. */
12
+ hydrate?: string[];
9
13
  };
10
14
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
15
  declare const _default: typeof __VLS_export;
@@ -0,0 +1,10 @@
1
+ import { type ComarkPlugin } from "comark";
2
+ type __VLS_Props = {
3
+ value?: string;
4
+ componentSet?: string;
5
+ plugins: ComarkPlugin[];
6
+ hydrate?: string[];
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,80 @@
1
+ <script setup>
2
+ import { isArray, isString } from "@onderwijsin/nuxt-module-utils/shared";
3
+ import { parseMarkdown } from "comark";
4
+ import { pascalCase, visit } from "comark/utils";
5
+ import { rendererComponentNames, resolveRendererComponent } from "#markdown-renderer/manifest";
6
+ import { defineComponent, getCurrentInstance, h } from "vue";
7
+ import { ssrRenderVNode } from "vue/server-renderer";
8
+ import MarkdownIslandLink from "./MarkdownIslandLink.vue";
9
+ import MarkdownIslandOutlet from "./MarkdownIslandOutlet.vue";
10
+ const props = defineProps({
11
+ value: { type: String, required: false },
12
+ componentSet: { type: String, required: false },
13
+ plugins: { type: Array, required: true },
14
+ hydrate: { type: Array, required: false }
15
+ });
16
+ const document = await parseMarkdown((props.value ?? "").trim(), { plugins: props.plugins });
17
+ const components = { ProseA: MarkdownIslandLink };
18
+ const requested = /* @__PURE__ */ new Set();
19
+ const nested = /* @__PURE__ */ new Set();
20
+ const roots = new Set(document.nodes);
21
+ function isElement(node) {
22
+ return isArray(node) && node[0] !== null;
23
+ }
24
+ visit(document, isElement, (node) => {
25
+ if (!isElement(node)) return;
26
+ for (const tag of [node[0], node[1].as]) {
27
+ if (!isString(tag)) continue;
28
+ requested.add(tag);
29
+ if (!roots.has(node)) nested.add(pascalCase(tag));
30
+ }
31
+ });
32
+ await Promise.all(
33
+ [...requested].map(async (tag) => {
34
+ const name = pascalCase(tag);
35
+ if (!rendererComponentNames.includes(name)) return;
36
+ const resolved = await resolveRendererComponent(tag, props.componentSet);
37
+ if (!resolved) {
38
+ components[name] = (_, { attrs, slots }) => h(tag, attrs, slots.default?.());
39
+ return;
40
+ }
41
+ components[name] = props.hydrate?.includes(name) && !nested.has(name) ? createIslandWidget(tag) : resolved.default;
42
+ })
43
+ );
44
+ async function readSlotHtml(item) {
45
+ if (isString(item)) return item;
46
+ return (await Promise.all((await item).map(readSlotHtml))).join("");
47
+ }
48
+ function createIslandWidget(tag) {
49
+ const { componentSet } = props;
50
+ return defineComponent({
51
+ inheritAttrs: false,
52
+ setup(_, { attrs, slots }) {
53
+ const parent = getCurrentInstance();
54
+ if (!parent) throw new Error("Markdown island slots require a Vue component instance.");
55
+ return () => {
56
+ const renderedSlots = Promise.all(
57
+ Object.entries(slots).map(async ([name, slot]) => {
58
+ const buffer = [];
59
+ ssrRenderVNode(
60
+ (item) => buffer.push(item),
61
+ h("span", { style: "display:contents" }, slot?.()),
62
+ parent
63
+ );
64
+ return [name, (await Promise.all(buffer.map(readSlotHtml))).join("")];
65
+ })
66
+ );
67
+ const Widget = defineComponent(async () => {
68
+ const slotHtml = Object.fromEntries(await renderedSlots);
69
+ return () => h(MarkdownIslandOutlet, { tag, componentSet, attributes: attrs, slotHtml });
70
+ });
71
+ return h(Widget);
72
+ };
73
+ }
74
+ });
75
+ }
76
+ </script>
77
+
78
+ <template>
79
+ <MarkdownDocument :value="document" :components="components" />
80
+ </template>
@@ -0,0 +1,10 @@
1
+ import { type ComarkPlugin } from "comark";
2
+ type __VLS_Props = {
3
+ value?: string;
4
+ componentSet?: string;
5
+ plugins: ComarkPlugin[];
6
+ hydrate?: string[];
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,20 @@
1
+ <script setup>
2
+ import { createStaticVNode } from "vue";
3
+ import { resolveRendererComponent } from "#markdown-renderer/manifest";
4
+ defineOptions({ inheritAttrs: false });
5
+ const props = defineProps({
6
+ tag: { type: String, required: true },
7
+ componentSet: { type: String, required: false },
8
+ attributes: { type: Object, required: true },
9
+ slotHtml: { type: Object, required: true }
10
+ });
11
+ const component = (await resolveRendererComponent(props.tag, props.componentSet))?.default;
12
+ </script>
13
+
14
+ <template>
15
+ <component :is="component" v-if="component" v-bind="attributes">
16
+ <template v-for="(html, name) in slotHtml" #[name]>
17
+ <component :is="() => createStaticVNode(html, 1)" />
18
+ </template>
19
+ </component>
20
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fileoverview
3
+ *
4
+ * Renders styled prose anchors in an island. NuxtLink resolves internal paths and the
5
+ * `data-internal` marker lets Nuxt handle navigation for those anchors.
6
+ */
7
+ import { ProseA } from "#components";
8
+ type __VLS_Props = {
9
+ href?: string;
10
+ target?: InstanceType<typeof ProseA>["$props"]["target"];
11
+ };
12
+ declare var __VLS_14: {}, __VLS_23: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_14) => any;
15
+ } & {
16
+ default?: (props: typeof __VLS_23) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import { ProseA } from "#components";
3
+ import { computed } from "vue";
4
+ defineOptions({ inheritAttrs: false });
5
+ const props = defineProps({
6
+ href: { type: String, required: false },
7
+ target: { type: null, required: false }
8
+ });
9
+ const internal = computed(
10
+ () => !!props.href && props.href.startsWith("/") && !props.href.startsWith("//") && (!props.target || props.target === "_self")
11
+ );
12
+ </script>
13
+
14
+ <template>
15
+ <NuxtLink v-if="internal" :to="href" custom v-slot="{ href: resolvedHref }">
16
+ <ProseA v-bind="$attrs" :href="resolvedHref ?? void 0" :target="target" data-internal="">
17
+ <slot />
18
+ </ProseA>
19
+ </NuxtLink>
20
+ <ProseA v-else v-bind="$attrs" :href="href" :target="target">
21
+ <slot />
22
+ </ProseA>
23
+ </template>
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fileoverview
3
+ *
4
+ * Renders styled prose anchors in an island. NuxtLink resolves internal paths and the
5
+ * `data-internal` marker lets Nuxt handle navigation for those anchors.
6
+ */
7
+ import { ProseA } from "#components";
8
+ type __VLS_Props = {
9
+ href?: string;
10
+ target?: InstanceType<typeof ProseA>["$props"]["target"];
11
+ };
12
+ declare var __VLS_14: {}, __VLS_23: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_14) => any;
15
+ } & {
16
+ default?: (props: typeof __VLS_23) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,13 @@
1
+ <script setup>
2
+ import MarkdownIslandClient from "./MarkdownIslandClient.vue";
3
+ defineProps({
4
+ tag: { type: String, required: true },
5
+ componentSet: { type: String, required: false },
6
+ attributes: { type: Object, required: true },
7
+ slotHtml: { type: Object, required: true }
8
+ });
9
+ </script>
10
+
11
+ <template>
12
+ <MarkdownIslandClient nuxt-client v-bind="$props" />
13
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -1,13 +1,11 @@
1
- type ComponentLoader = () => Promise<unknown>;
2
1
  /**
3
2
  * Creates the runtime resolver around build-time generated lazy component imports.
4
3
  * @param componentLoaders Lazy imports keyed by renderer component name.
5
4
  * @param componentSets Configured component allowlists.
6
5
  * @returns Runtime manifest values consumed by `MarkdownRenderer` and metadata generation.
7
6
  */
8
- export declare function createRendererManifest(componentLoaders: Record<string, ComponentLoader>, componentSets: Record<string, string[]>): {
7
+ export declare function createRendererManifest<Module>(componentLoaders: Record<string, () => Promise<Module>>, componentSets: Record<string, string[]>): {
9
8
  componentSets: Record<string, string[]>;
10
9
  rendererComponentNames: string[];
11
- resolveRendererComponent(name: string, componentSet?: string): Promise<unknown> | null;
10
+ resolveRendererComponent(name: string, componentSet?: string): Promise<Module> | null;
12
11
  };
13
- export {};
@@ -7,11 +7,11 @@ export function createRendererManifest(componentLoaders, componentSets) {
7
7
  rendererComponentNames: Object.keys(componentLoaders),
8
8
  resolveRendererComponent(name, componentSet) {
9
9
  const normalizedName = resolveComponentName(name);
10
- const allowedComponents = componentSet ? componentSets[componentSet] : void 0;
10
+ const allowedComponents = componentSet && Object.hasOwn(componentSets, componentSet) ? componentSets[componentSet] : void 0;
11
11
  if (normalizedName !== "Reference" && normalizedName !== "RelatedItemList" && componentSet && (!allowedComponents || !allowedComponents.includes(normalizedName))) {
12
12
  return null;
13
13
  }
14
- return componentLoaders[normalizedName]?.() ?? null;
14
+ return Object.hasOwn(componentLoaders, normalizedName) ? componentLoaders[normalizedName]?.() ?? null : null;
15
15
  }
16
16
  };
17
17
  }
@@ -1,18 +1,19 @@
1
1
  declare module "#markdown-renderer/manifest" {
2
- import type { ComponentManifest } from "comark";
2
+ import type { Component } from "vue";
3
3
 
4
4
  export const componentSets: Record<string, string[]>;
5
5
  export const rendererComponentNames: string[];
6
6
  export const resolveRendererComponent: (
7
7
  name: string,
8
8
  componentSet?: string
9
- ) => ReturnType<ComponentManifest>;
9
+ ) => Promise<{ default: Component }> | null;
10
10
  }
11
11
 
12
12
  declare module "nuxt/schema" {
13
13
  interface AppConfig {
14
14
  markdownRenderer: {
15
15
  videoBaseUrl?: string;
16
+ selectiveHydration?: boolean;
16
17
  };
17
18
  }
18
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-markdown-renderer",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Nuxt module for rendering Markdown content.",
5
5
  "homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
6
6
  "bugs": {