Nuxt Content는 프로젝트의 content/ 디렉터리를 읽고 .md, .yml, .csv, .json 파일을 파싱하여 애플리케이션을 위한 파일 기반 CMS를 생성합니다.
@nuxt/content 모듈을 프로젝트에 설치하고, 동시에 nuxt.config.ts에 추가하려면 다음 한 줄 명령을 사용하세요:
npx nuxt module add content
Markdown 파일을 content/ 디렉터리 안에 배치하세요:
# Hello Content
모듈이 이를 자동으로 로드하고 파싱합니다.
콘텐츠 페이지를 렌더링하려면 <ContentRenderer> 컴포넌트를 사용해 catch-all 라우트를 추가하세요:
<script lang="ts" setup>
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})
</script>
<template>
<div>
<header><!-- ... --></header>
<ContentRenderer
v-if="page"
:value="page"
/>
<footer><!-- ... --></footer>
</div>
</template>