-
Notifications
You must be signed in to change notification settings - Fork 3
/
Blocks.vue
48 lines (43 loc) · 1.23 KB
/
Blocks.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script setup lang="ts">
import type { KirbyBlock } from '#nuxt-kql'
import type { ComponentPublicInstance } from 'vue'
import {
LazyKirbyBlockHeading,
LazyKirbyBlockImage,
LazyKirbyBlockIntro,
LazyKirbyBlockLine,
LazyKirbyBlockList,
LazyKirbyBlockNoteHeader,
LazyKirbyBlockNotesGrid,
LazyKirbyBlockQuote,
LazyKirbyBlockTeamStructure,
LazyKirbyBlockText,
} from '#components'
defineProps<{
blocks: KirbyBlock<string>[]
}>()
type ComponentConstructor = new (...args: any[]) => ComponentPublicInstance
const blockComponents: Record<string, ComponentConstructor> = {
// Built-in Kirby blocks
heading: LazyKirbyBlockHeading,
image: LazyKirbyBlockImage,
line: LazyKirbyBlockLine,
list: LazyKirbyBlockList,
quote: LazyKirbyBlockQuote,
text: LazyKirbyBlockText,
// Custom blocks
intro: LazyKirbyBlockIntro,
'note-header': LazyKirbyBlockNoteHeader,
'notes-grid': LazyKirbyBlockNotesGrid,
'team-structure': LazyKirbyBlockTeamStructure,
}
const content = ref<HTMLElement | undefined>()
useInternalLinks(content)
</script>
<template>
<div ref="content">
<template v-for="(block, index) in blocks" :key="index">
<component :is="blockComponents[block.type]" :block="block" />
</template>
</div>
</template>