Skip to content

Commit fcfc48f

Browse files
committed
详细介绍和组织历程页面
1 parent f49af39 commit fcfc48f

5 files changed

Lines changed: 93 additions & 10 deletions

File tree

app/pages/[...slug].vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ useSeoMeta(page.value?.seo || {})
1818

1919
<template>
2020
<NuxtLayout :name="'article'" class="bg-white dark:bg-gray-800 ring-1 ring-gray-200 dark:ring-gray-700">
21-
<div v-if="!page">
22-
未找到
23-
</div>
24-
<div v-else>
25-
<ContentRenderer
21+
<ContentRenderer
2622
v-if="page"
2723
:value="page"
2824
class="prose dark:prose-invert prose-pre:bg-gray-100 dark:prose-pre:bg-gray-900"
2925
/>
30-
</div>
3126
<div class="flex justify-center">
3227
<Button @click="navigateTo('/')" class="bg-blue-100 text-gray-500 border border-blue-300 px-4 py-3 rounded">返回主页</Button>
3328
</div>

app/pages/history.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div>
3+
<Title>组织历程</Title>
4+
<Hero />
5+
<div class="flex justify-center px-4">
6+
<div class="w-full max-w-4xl">
7+
<ul class="space-y-6">
8+
<li v-for="his in history" :key="his.id">
9+
<div v-if="!his" class="text-center text-gray-500 py-8">
10+
文章未找到
11+
</div>
12+
<div v-else class="bg-blue- rounded-lg shadow-md p-6">
13+
<ContentRenderer :value="his" />
14+
</div>
15+
</li>
16+
</ul>
17+
</div>
18+
</div>
19+
<div class="flex justify-center gap-10">
20+
<Button @click="navigateTo('/')" class="bg-blue-400 text-gray-500 border border-blue-300 px-4 py-3 rounded">
21+
返回主页
22+
</Button>
23+
</div>
24+
</div>
25+
</template>
26+
27+
<script setup lang="ts">
28+
const { data: history } = await useAsyncData(() => {
29+
return queryCollection('history').all();
30+
});
31+
32+
if (!history.value) {
33+
throw createError({
34+
statusCode: 404,
35+
statusMessage: 'Page not found',
36+
});
37+
}
38+
</script>

app/pages/introduction.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<div>
3+
<Title>详细介绍</Title>
4+
<Hero />
5+
<div class="flex justify-center px-4">
6+
<div class="w-full max-w-4xl">
7+
<ul class="space-y-6">
8+
<li v-for="intro in introducions" :key="intro.id">
9+
<div v-if="!intro" class="text-center text-gray-500 py-8">
10+
文章未找到
11+
</div>
12+
<div v-else class="bg-blue- rounded-lg shadow-md p-6">
13+
<ContentRenderer :value="intro" />
14+
</div>
15+
</li>
16+
</ul>
17+
</div>
18+
</div>
19+
<div class="flex justify-center gap-10">
20+
<Button @click="navigateTo('/')" class="bg-blue-400 text-gray-500 border border-blue-300 px-4 py-3 rounded">
21+
返回主页
22+
</Button>
23+
</div>
24+
</div>
25+
</template>
26+
27+
<script setup lang="ts">
28+
const { data: introducions } = await useAsyncData(() => {
29+
return queryCollection('introduction').all();
30+
});
31+
32+
if (!introducions.value) {
33+
throw createError({
34+
statusCode: 404,
35+
statusMessage: 'Page not found',
36+
});
37+
}
38+
</script>

content.config.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
import { defineCollection, defineContentConfig,z } from '@nuxt/content';
1+
import { defineCollection, defineContentConfig, z } from '@nuxt/content';
22

33
export default defineContentConfig({
44
collections: {
55
history: defineCollection({
66
type: 'page',
77
source: 'history/**/*.md',
88
schema: z.object({
9-
date: z.string()
9+
date: z.string(),
1010
}),
1111
}),
12-
}
13-
})
12+
introduction: defineCollection({
13+
type: 'page',
14+
source: 'introduction/**/*.md',
15+
schema: z.object({
16+
date: z.string(),
17+
}),
18+
}),
19+
},
20+
});

content/introduction/intro2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
date: '2025-9-34'
3+
---
4+
5+
**这里是介绍页面的测试**

0 commit comments

Comments
 (0)