Skip to content

Commit

Permalink
Migrate nuxt content components and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gb-beng committed Sep 27, 2023
1 parent 2b1396e commit a73515e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/dataset/TabDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</v-row>

<!-- Description -->
<nuxt-content :document="page" />
<ContentRenderer :value="page" />

<!-- Chiplist -->
<v-row class="justify-center mt-5">
Expand Down
2 changes: 1 addition & 1 deletion components/dataset/TabOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</v-row>

<!-- Description -->
<nuxt-content :document="page" />
<ContentRenderer id="nuxt-content" :value="page" />

<!-- Chiplist -->
<v-row class="justify-center mt-5">
Expand Down
7 changes: 6 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,10 @@ export default defineNuxtConfig({
},
],
},
}
},
content: {
markdown: {
anchorLinks: false,
},
},
})
10 changes: 5 additions & 5 deletions pages/about.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Content -->
<template #content>
<section class="mt-4">
<nuxt-content :document="page" />
<ContentRenderer class="nuxt-content" :value="page" />
</section>
</template>
</HeaderPage>
Expand All @@ -34,10 +34,10 @@ const { data: page } = await useAsyncData(async () => {
})
defineI18nRoute({
paths: {
en: '/about',
nl: '/over-ons',
},
paths: {
en: '/about',
nl: '/over-ons',
},
})
useHead({
Expand Down
6 changes: 5 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@
md="6"
class="pa-10 d-flex flex-column justify-center align-start"
>
<nuxt-content :document="{ body: aboutPage.excerpt }" />
<ContentRenderer
class="nuxt-content"
:value="aboutPage"
:excerpt="true"
/>
<v-btn color="primary" :to="localePath('about')">
{{ $t('read_more') }}
</v-btn>
Expand Down
12 changes: 12 additions & 0 deletions server/plugins/content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import path from 'path'

export default defineNitroPlugin((nitroApp) => {
// add slug field based on path, for compatibility with Nuxt Content v1.
// https://github.com/nuxt/content/blob/776e428eb2987e5a8c237fbc90e2d9beb8e3b0e3/packages/content/lib/database.js#L271
// https://content.nuxtjs.org/api/advanced#contentfileafterparse
nitroApp.hooks.hook('content:file:afterParse', (file) => {
if (file._id.endsWith('.md')) {
file.slug = path.basename(file._path)
}
})
})

0 comments on commit a73515e

Please sign in to comment.