Skip to content

Commit acd1e39

Browse files
committed
embed markdown component
1 parent bafe970 commit acd1e39

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

app/components/EmbedMarkdown.vue

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<script setup lang="ts">
2+
interface Props {
3+
collection: string
4+
path: string
5+
}
6+
7+
const props = defineProps<Props>()
8+
9+
const { data: content } = await useAsyncData(
10+
() => `embed-${props.collection}-${props.path}`,
11+
() =>
12+
queryCollection(props.collection as any)
13+
.where('stem', '=', props.path)
14+
.first()
15+
)
16+
17+
const { data: availableContent } = await useAsyncData(
18+
() => `available-${props.collection}`,
19+
() => queryCollection(props.collection as any).all()
20+
)
21+
</script>
22+
23+
<template>
24+
<div v-if="content">
25+
<ContentRenderer :value="content" />
26+
</div>
27+
<div v-else class="border border-red-200 rounded-lg p-4 bg-red-50 text-red-800">
28+
<p class="font-semibold mb-2">Content "{{ path }}" not found in collection "{{ collection }}"</p>
29+
<p class="text-sm mb-2">Available content in this collection:</p>
30+
<ul class="list-disc list-inside text-sm space-y-1">
31+
<li v-for="item in availableContent" :key="item.stem" class="font-mono">
32+
{{ item.stem }}
33+
</li>
34+
</ul>
35+
<p v-if="!availableContent?.length" class="text-sm italic">
36+
No content found in collection "{{ collection }}"
37+
</p>
38+
</div>
39+
</template>

content.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export default defineContentConfig({
2626
type: 'page',
2727
source: 'pinion/docs/**/*.md',
2828
}),
29+
pinionShared: defineCollection({
30+
type: 'page',
31+
source: 'pinion/shared/**/*.md',
32+
}),
2933
feathersDocs: defineCollection({
3034
type: 'page',
3135
source: 'feathers/docs/**/*.md',

0 commit comments

Comments
 (0)