17 lines
746 B
Vue
17 lines
746 B
Vue
<script setup lang="ts">
|
|
import { computed, type Component } from 'vue';
|
|
import { blockComponents } from './components';
|
|
import type { Block } from './support';
|
|
|
|
// Draws the blocks of a page (`Blocks::for()` as a prop): one component per type. `components` replaces or adds a type of the site;
|
|
// a type without a component draws nothing.
|
|
const props = defineProps<{ blocks: Block[]; components?: Record<string, Component> }>();
|
|
const map = computed(() => ({ ...blockComponents, ...(props.components ?? {}) }));
|
|
</script>
|
|
|
|
<template>
|
|
<template v-for="block in blocks" :key="block.id">
|
|
<component :is="map[block.type]" v-if="map[block.type]" :data="block.data" :style="block.style" :items="block.items" />
|
|
</template>
|
|
</template>
|