Skip to content

Commit fae38d7

Browse files
committed
reproduce body edition with data type
1 parent 7bc43c0 commit fae38d7

File tree

6 files changed

+85
-1
lines changed

6 files changed

+85
-1
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts">
2+
import type { MarkdownRoot } from '@nuxt/content'
3+
import { decompressTree } from '@nuxt/content/runtime'
4+
5+
const { data: datas } = await useAsyncData('datas-collection', async () => {
6+
const items = await queryCollection('datas').order('order', 'ASC').all()
7+
return items.map(item => ({
8+
...item,
9+
body: item.meta?.body ? decompressTree(item.meta.body as MarkdownRoot) : null,
10+
}))
11+
})
12+
</script>
13+
14+
<template>
15+
<div>
16+
<UContainer class="m-4">
17+
<h1 class="text-2xl font-bold mb-4">
18+
Data Collection
19+
</h1>
20+
<div class="flex flex-col gap-4">
21+
<UCard
22+
v-for="item in datas"
23+
:key="item.stem"
24+
:to="item.link"
25+
target="_blank"
26+
>
27+
<div class="flex items-center gap-2 mb-2">
28+
<UIcon
29+
:name="item.icon"
30+
class="w-5 h-5"
31+
/>
32+
<h2 class="text-lg font-semibold">
33+
{{ item.title }}
34+
</h2>
35+
</div>
36+
<MDCRenderer
37+
v-if="item.body"
38+
:body="item.body"
39+
/>
40+
<img
41+
:src="item.image"
42+
:alt="item.title"
43+
class="w-full h-32 object-cover rounded mb-2"
44+
>
45+
</UCard>
46+
</div>
47+
</UContainer>
48+
</div>
49+
</template>
File renamed without changes.

playground/docus/content.config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ const collections: Record<string, DefinedCollection> = {
3030
prefix: '/',
3131
},
3232
}),
33+
datas: defineCollection({
34+
type: 'data',
35+
source: {
36+
include: '4.datas/**/*.md',
37+
prefix: '/',
38+
},
39+
schema: z.object({
40+
title: z.string().nonempty(),
41+
link: z.string().nonempty(),
42+
icon: z.string().nonempty().editor({ input: 'icon' }),
43+
image: z.string().nonempty().editor({ input: 'media' }),
44+
order: z.number(),
45+
}),
46+
}),
3347
landing: defineCollection({
3448
type: 'page',
3549
source: {
@@ -40,7 +54,7 @@ const collections: Record<string, DefinedCollection> = {
4054
type: 'page',
4155
source: {
4256
include: '**',
43-
exclude: ['index.md', '3.pages/**/*.md', 'authors/**/*'],
57+
exclude: ['index.md', '3.pages/**/*.md', 'authors/**/*', '4.datas/**/*.md'],
4458
},
4559
schema: createDocsSchema(),
4660
}),
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Nuxt Framework
3+
link: https://nuxt.com
4+
icon: i-simple-icons-nuxtdotjs
5+
image: /mountains.webp
6+
order: 1
7+
---
8+
9+
The Intuitive Vue Framework. Build your next Vue.js application with confidence using Nuxt.
10+
11+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Vue.js
3+
link: https://vuejs.org
4+
icon: i-simple-icons-vuedotjs
5+
image: /mountains.webp
6+
order: 2
7+
---
8+
9+
The Progressive JavaScript Framework. An approachable, performant and versatile framework for building web user interfaces.
10+

0 commit comments

Comments
 (0)