Skip to content

Commit b5e5ef6

Browse files
committed
add toggle to headers
1 parent 9b1f076 commit b5e5ef6

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

src/blocks/header.vue

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
<script setup lang="ts">
2-
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
3-
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue"
2+
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
3+
import NotionHeaderRenderer from "@/blocks/helpers/header-renderer.vue";
4+
import NotionRenderer from "@/components/notion-renderer.vue";
45
5-
const props = defineProps({ ...defineNotionProps })
6+
const props = defineProps({ ...defineNotionProps });
67
//@ts-ignore
7-
const { type, title, pass, block } = useNotionBlock(props)
8+
const { type, title, pass, block, format } = useNotionBlock(props);
89
</script>
910

1011
<script lang="ts">
1112
export default {
1213
name: "NotionHeader",
13-
}
14+
};
1415
</script>
1516

1617
<template>
17-
<h1 class="notion-h1" :id="block.value.id" v-if="type === 'header'">
18-
<NotionTextRenderer :text="title" v-bind="pass" />
19-
</h1>
20-
<h2 class="notion-h2" :id="block.value.id" v-else-if="type === 'sub_header'">
21-
<NotionTextRenderer :text="title" v-bind="pass" />
22-
</h2>
23-
<h3 class="notion-h3" :id="block.value.id" v-else-if="type === 'sub_sub_header'">
24-
<NotionTextRenderer :text="title" v-bind="pass" />
25-
</h3>
18+
<details v-if="format?.toggleable" class="notion-toggle">
19+
<summary><NotionHeaderRenderer class="notion-h" v-bind="pass"></NotionHeaderRenderer></summary>
20+
<div>
21+
<NotionRenderer
22+
v-for="(contentId, contentIndex) in block.value.content"
23+
v-bind="pass"
24+
:key="contentId"
25+
:level="pass.level + 1"
26+
:content-id="contentId"
27+
:content-index="contentIndex"
28+
></NotionRenderer>
29+
</div>
30+
</details>
31+
<NotionHeaderRenderer v-else v-bind="pass"></NotionHeaderRenderer>
2632
</template>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup lang="ts">
2+
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
3+
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue";
4+
5+
const props = defineProps({ ...defineNotionProps });
6+
//@ts-ignore
7+
const { type, title, pass, block } = useNotionBlock(props);
8+
</script>
9+
10+
<script lang="ts">
11+
export default {
12+
name: "NotionHeaderRenderer",
13+
};
14+
</script>
15+
16+
<template>
17+
<h1 class="notion-h1" :id="block.value.id" v-if="type === 'header'">
18+
<NotionTextRenderer :text="title" v-bind="pass" />
19+
</h1>
20+
<h2 class="notion-h2" :id="block.value.id" v-else-if="type === 'sub_header'">
21+
<NotionTextRenderer :text="title" v-bind="pass" />
22+
</h2>
23+
<h3 class="notion-h3" :id="block.value.id" v-else-if="type === 'sub_sub_header'">
24+
<NotionTextRenderer :text="title" v-bind="pass" />
25+
</h3>
26+
</template>

0 commit comments

Comments
 (0)