Skip to content

Commit b9022fc

Browse files
committed
feat(content): Move toNuxt Content 3.1
1 parent a658d48 commit b9022fc

File tree

6 files changed

+465
-173
lines changed

6 files changed

+465
-173
lines changed

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

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
<script setup lang='ts'>
1+
<script lang="ts" setup>
22
const route = useRoute()
3-
const slug = route.params.slug?.toString()
3+
const path = route.path.replace('/cms', '')
4+
const { data: page } = await useAsyncData('page-' + path, () => {
5+
return queryCollection('content').path(path).first()
6+
})
47
</script>
58

69
<template>
7-
<div class="markdown">
8-
<ContentDoc :path="slug">
9-
<template #default="{ doc }">
10-
<div class="card">
11-
<h2>{{ doc.title }}</h2>
12-
<p>{{ doc.description }}</p>
13-
<p class="font-bold">
14-
Author: {{ doc.author }}
15-
</p>
16-
<hr>
17-
<ContentRenderer :value="doc" />
18-
</div>
19-
</template>
20-
<!-- Slot if document is not found -->
21-
<template #not-found>
22-
<h1 class="text-2xl">
23-
Content Page ({{ slug }}) not found
24-
</h1>
25-
</template>
26-
</contentdoc>
27-
</div>
28-
</template>
10+
<div class="card">
11+
<h2>{{ page?.title }}</h2>
12+
<p>{{ page?.description }}</p>
13+
<p class="font-bold">
14+
Author: {{ page?.meta.author }}
15+
</p>
16+
<hr>
17+
18+
<ContentRenderer v-if="page" :value="page" />
2919

30-
<style scoped></style>
20+
<footer><!-- ... --></footer>
21+
</div>
22+
</template>

app/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import AdvertiseBox from '@/components/AdvertiseBox.vue'
3434
<AdvertiseBox header="Nuxt 3.14.x (Nuxt 4 ready)" icon="prime-check-circle" color="green-400">
3535
<ExternalLink href="https://nuxt.com/" text="Nuxt" /> with Pages, Layouts, ...
3636
</AdvertiseBox>
37-
<AdvertiseBox header="Nuxt Content 2.13.x" icon="prime-check-circle" color="green-400">
37+
<AdvertiseBox header="Nuxt Content 3.1.x" icon="prime-check-circle" color="green-400">
3838
<ExternalLink href="https://content.nuxt.com/" text="Content" />: Markdown, YML, CSV or JSON and MDC Syntax
3939
</AdvertiseBox>
4040
<AdvertiseBox header="Nuxt Modules" icon="prime-check-circle" color="green-600">

content.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineContentConfig, defineCollection } from '@nuxt/content'
2+
3+
export default defineContentConfig({
4+
collections: {
5+
content: defineCollection({
6+
type: 'page',
7+
source: '**/*.md'
8+
})
9+
}
10+
})

nuxt.config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ export default defineNuxtConfig({
3535
],
3636
content: {
3737
highlight: {
38-
theme: 'one-dark-pro',
39-
preload: ['json', 'js', 'ts', 'html', 'css', 'vue'],
40-
},
41-
// Options
38+
theme: {
39+
// Default theme (same as single string)
40+
default: 'github-light',
41+
// Theme used if `html.dark`
42+
dark: 'github-dark',
43+
44+
}
45+
}
4246
},
4347

4448
i18n: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@iconify-json/mdi": "^1.2.3",
2626
"@iconify-json/prime": "^1.2.2",
2727
"@iconify-json/twemoji": "^1.2.2",
28-
"@nuxt/content": "^2.13.4",
28+
"@nuxt/content": "^3.1.0",
2929
"@nuxt/devtools": "2.0.0",
3030
"@nuxt/fonts": "^0.10.3",
3131
"@nuxt/image": "^1.9.0",

0 commit comments

Comments
 (0)