diff --git a/playground/server/routes/ce-api/node/unified.ts b/playground/server/routes/ce-api/node/unified.ts new file mode 100644 index 00000000..8e0cc60a --- /dev/null +++ b/playground/server/routes/ce-api/node/unified.ts @@ -0,0 +1,27 @@ +export default defineEventHandler(() => ({ + title: 'Another page', + messages: [], + breadcrumbs: [], + metatags: {}, + content_format: 'json', + content: { + element: 'node', + slots: { + image: 'test', + body: { + element: 'node', + slots: { + body: '

2nd example body.

', + }, + props: { + title: 'Title2', + }, + }, + }, + props: { + title: 'Title', + }, + }, + page_layout: 'clear', + local_tasks: [], +})) diff --git a/src/runtime/composables/useDrupalCe/index.ts b/src/runtime/composables/useDrupalCe/index.ts index 4e7dac0b..4896c253 100644 --- a/src/runtime/composables/useDrupalCe/index.ts +++ b/src/runtime/composables/useDrupalCe/index.ts @@ -324,7 +324,17 @@ export const useDrupalCe = () => { // Handle single custom element object const { element, ...props } = customElements const resolvedElement = resolveCustomElement(element) - return resolvedElement ? h(resolvedElement, props) : null + + // Handle slots + const slots = {} + if (customElements?.slots && Object.keys(customElements?.slots)?.length) { + Object.entries(customElements?.slots).forEach(([key, element]) => { + const rendered = renderCustomElements(element) + slots[key] = rendered ? () => h(rendered) : null + }) + } + + return resolvedElement ? h(resolvedElement, { ...props, ...props.props }, slots) : null } /**