---
color: neutral
label: 打开可视化编辑器
size: xl
target: _blank
to: https://nuxt.studio
variant: subtle
---
::my-vue-hero-component{orientation="horizontal"}
#title
欢迎来到山脉网站。
#description
这是一个关于山脉的网站描述。
::
这是一个包含 **加粗** 和 _斜体_ 文本的段落。
<script setup lang="ts">
const { data } = await useAsyncData('home', () => {
return queryCollection('content').path('/').first()
})
useSeoMeta({
title: data.value?.title,
description: data.value?.description
})
</script>
<template>
<ContentRenderer :value="data" />
</template>
结合基于文件的简单性与 Vue 组件的强大功能。构建内容丰富的网站,从文档页到复杂应用。
# 来定义组件插槽
---
title: 山脉网站
description: 一个关于世界上最具标志性的山脉的网站。
---
::landing-hero
---
image: /mountains/everest.jpg
---
#title
珠穆朗玛峰
#description
珠穆朗玛峰是世界上最高的山,海拔 8,848 米。
::
<script setup lang="ts">
defineProps<{
image: string
}>()
</script>
<template>
<section class="flex flex-col sm:flex-row sm:items-center gap-4 py-8 sm:gap-12 sm:py-12">
<div>
<h1 class="text-4xl font-semibold">
<slot name="title" />
</h1>
<div class="text-base text-gray-600 dark:text-gray-300">
<slot name="description" />
</div>
</div>
<img :src="image" class="w-1/2 rounded-lg">
</section>
</template>
<script setup lang="ts">
const { data: posts } = await useAsyncData('blog', () => {
return queryCollection('blog').all()
})
</script>
<template>
<div>
<h1>博客</h1>
<ul>
<li v-for="post in posts" :key="post.id">
<NuxtLink :to="post.path">{{ post.title }}</NuxtLink>
</li>
</ul>
</div>
</template>
import { defineContentConfig, defineCollection } from '@nuxt/content'
import { z } from 'zod'
export default defineContentConfig({
collections: {
blog: defineCollection({
source: 'blog/*.md',
type: 'page',
// 定义文档集合的自定义 schema
schema: z.object({
tags: z.array(z.string()),
image: z.string(),
date: z.Date()
})
})
}
})
YAML 与 JSON 文件生成的表单。支持实时预览和在线协作。