Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update to nuxt/content v3 #1523

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/components/StaticMarkdownRender.server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ContentRendererMarkdown } from '#components'
import { ContentRenderer } from '#components'

export default defineComponent({
props: {
path: String,
collection: { type: String as () => 'page' | 'blog', required: true },
path: { type: String, required: true },
},
async setup (props) {
if (import.meta.dev) {
const { data } = await useAsyncData(() =>
queryContent(props.path!).findOne(),
queryCollection(props.collection).path(props.path!).first(),
)
return () => h(ContentRendererMarkdown, { value: data.value! })
return () => h(ContentRenderer, { value: data.value! })
}
const value = await queryContent(props.path!).findOne()
return () => h(ContentRendererMarkdown, { value })
const value = await queryCollection(props.collection).path(props.path!).first()
return () => h(ContentRenderer, { value })
},
})
12 changes: 4 additions & 8 deletions app/components/TheBlogIndex.server.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<script setup lang="ts">
const entries = await queryContent('/blog')
.only(['title', 'date', '_path'])
.find()
const entries = await queryCollection('blog')
.select('title', 'date', 'path')
.all()
.then(result => {
return (result as Array<{ title?: string, date: string, _path: string }>)
.map(e => ({
...e,
path: e._path,
}))
return result
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
})
</script>
Expand Down
12 changes: 3 additions & 9 deletions app/components/TheHome.server.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ const { data: streams } = await useFetch('/api/streams', {
})

const { data: articles } = await useAsyncData(async () => {
const result = await queryContent('/blog')
.only(['title', 'date', '_path'])
.find()
return (result as Array<{ title?: string, date: string, _path: string }>)
.map(e => ({
...e,
path: e._path,
}))
const result = await queryCollection('blog').select('title', 'date', 'path').all()
return result
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
.slice(0, 4)
})
Expand Down Expand Up @@ -355,7 +349,7 @@ const { data: talks } = await useAsyncData(
<ul class="flex flex-col mt-4">
<li
v-for="article in articles"
:key="article._path"
:key="article.path"
class="py-2"
>
<NuxtLink
Expand Down
5 changes: 4 additions & 1 deletion app/pages/ai.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</header>

<main class="text-muted text-lg max-w-[37.50rem]">
<StaticMarkdownRender path="/ai" />
<StaticMarkdownRender
collection="page"
path="/ai"
/>
</main>
</div>
</template>
Expand Down
5 changes: 4 additions & 1 deletion app/pages/bio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
</header>

<main class="text-muted text-lg max-w-[37.50rem]">
<StaticMarkdownRender path="/bio" />
<StaticMarkdownRender
collection="page"
path="/bio"
/>
</main>
</div>
</template>
Expand Down
11 changes: 7 additions & 4 deletions app/pages/blog/[article].vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
v-if="page"
:class="$style.blog"
>
<StaticMarkdownRender :path="path" />
<StaticMarkdownRender
collection="blog"
:path="path"
/>
</section>
<WebMentions />
</main>
Expand All @@ -62,9 +65,9 @@ const { data: page } = await useAsyncData(
path.value,
() =>
((import.meta.server || import.meta.dev) as true)
&& queryContent(path.value)
.only(['title', 'date', 'tags', 'description'])
.findOne(),
&& queryCollection('blog').path(path.value)
.select('title', 'date', 'tags', 'description')
.first(),
)

if (!page.value) {
Expand Down
5 changes: 4 additions & 1 deletion app/pages/uses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
class="text-muted text-lg max-w-[37.50rem] text-base"
:class="$style.uses"
>
<StaticMarkdownRender path="/uses" />
<StaticMarkdownRender
collection="page"
path="/uses"
/>
</main>
</div>
</template>
Expand Down
21 changes: 21 additions & 0 deletions content.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineCollection, defineContentConfig, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
page: defineCollection({
source: '*.md',
type: 'page',
}),
blog: defineCollection({
source: 'blog/*.md',
type: 'page',
schema: z.object({
title: z.string(),
date: z.date(),
tags: z.array(z.string()),
description: z.string(),
skip_dev: z.boolean().optional(),
}),
}),
},
})
69 changes: 0 additions & 69 deletions modules/components-chunk.ts

This file was deleted.

9 changes: 0 additions & 9 deletions modules/runtime/remove-renderer.server.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@iconify-json/ri": "^1.2.5",
"@iconify-json/svg-spinners": "^1.2.2",
"@iconify-json/tabler": "^1.2.13",
"@nuxt/content": "2.13.4",
"@nuxt/content": "3.0.0",
"@nuxt/eslint": "0.7.5",
"@nuxt/fonts": "0.10.3",
"@nuxt/image": "1.9.0",
Expand Down
Loading
Loading