mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-02-02 07:31:31 +01:00
Add: nuxt content v3
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const { locale } = useI18n()
|
const { locale } = useI18n()
|
||||||
|
|
||||||
|
const { data: page } = await useAsyncData(`/home/${locale.value}`, () => {
|
||||||
|
return queryCollection('main').path(`/home/${locale.value}`).first()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main class="!max-w-none prose dark:prose-invert">
|
<main class="!max-w-none prose dark:prose-invert">
|
||||||
<ContentDoc :path="`/home/${locale}`" />
|
<ContentRenderer v-if="page" :value="page" />
|
||||||
<HomeMap />
|
<HomeMap />
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { data: post } = await useAsyncData(`portfolio:${route.params.slug}`, () => queryContent(`/portfolio/${route.params.slug}`).findOne())
|
const { data: post } = await useAsyncData(`portfolio/${route.params.slug}`, () =>
|
||||||
|
queryCollection('portfolio').path(`/portfolio/${route.params.slug}`).first())
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: postDB,
|
data: postDB,
|
||||||
refresh,
|
refresh,
|
||||||
} = await useAsyncData(`portfolio:${route.params.slug}:db`, () => $fetch(`/api/posts/${route.params.slug}`, { method: 'POST' }))
|
} = await useAsyncData(`portfolio/${route.params.slug}/db`, () => $fetch(`/api/posts/${route.params.slug}`, { method: 'POST' }))
|
||||||
|
|
||||||
const { locale, locales } = useI18n()
|
|
||||||
const currentLocale = computed(() => locales.value.filter(l => l.code === locale.value)[0])
|
|
||||||
|
|
||||||
|
const { locale } = useI18n()
|
||||||
const { t } = useI18n({
|
const { t } = useI18n({
|
||||||
useScope: 'local',
|
useScope: 'local',
|
||||||
})
|
})
|
||||||
@@ -122,12 +122,10 @@ async function handleLike() {
|
|||||||
icon="i-ph-pencil-line-duotone"
|
icon="i-ph-pencil-line-duotone"
|
||||||
/>
|
/>
|
||||||
<article class="mt-8">
|
<article class="mt-8">
|
||||||
<ContentRenderer :value="post">
|
<ContentRenderer
|
||||||
<ContentRendererMarkdown
|
:value="post"
|
||||||
:value="post"
|
class="!max-w-none prose dark:prose-invert"
|
||||||
class="!max-w-none prose dark:prose-invert"
|
/>
|
||||||
/>
|
|
||||||
</ContentRenderer>
|
|
||||||
<UDivider
|
<UDivider
|
||||||
class="my-16"
|
class="my-16"
|
||||||
icon="i-ph-hands-clapping-duotone"
|
icon="i-ph-hands-clapping-duotone"
|
||||||
@@ -188,6 +186,10 @@ async function handleLike() {
|
|||||||
.prose h4 a {
|
.prose h4 a {
|
||||||
@apply no-underline;
|
@apply no-underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.katex-html {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n lang="json">
|
<i18n lang="json">
|
||||||
|
|||||||
@@ -11,13 +11,10 @@ useSeoMeta({
|
|||||||
|
|
||||||
const tagFilter = ref<string | undefined>(undefined)
|
const tagFilter = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
const { data: writings, refresh } = await useAsyncData('all-portfolio', () => queryContent('/portfolio')
|
const { data: writings, refresh } = await useAsyncData('all-portfolio', () => queryCollection('portfolio')
|
||||||
.sort({ publishedAt: -1 })
|
.order('publishedAt', 'DESC')
|
||||||
.where({
|
.where('tags', 'LIKE', tagFilter.value ? `%${tagFilter.value}%` : '%')
|
||||||
tags: { $contains: tagFilter.value },
|
.all())
|
||||||
})
|
|
||||||
.without('body')
|
|
||||||
.find())
|
|
||||||
|
|
||||||
watch(tagFilter, async () => await refresh())
|
watch(tagFilter, async () => await refresh())
|
||||||
|
|
||||||
@@ -60,7 +57,7 @@ function updateTag(index: number) {
|
|||||||
<NuxtLink
|
<NuxtLink
|
||||||
v-for="(writing, id) in writings"
|
v-for="(writing, id) in writings"
|
||||||
:key="id"
|
:key="id"
|
||||||
:to="writing._path"
|
:to="writing.path"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
class=" h-full border p-4 shadow-sm border-neutral-200 rounded-md hover:border-neutral-500 dark:border-neutral-700 dark:hover:border-neutral-500 duration-300"
|
class=" h-full border p-4 shadow-sm border-neutral-200 rounded-md hover:border-neutral-500 dark:border-neutral-700 dark:hover:border-neutral-500 duration-300"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ useSeoMeta({
|
|||||||
description: t('description'),
|
description: t('description'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: items } = await useAsyncData('uses', () => queryContent('/uses').find())
|
const { data: items } = await useAsyncData('uses', async () => await queryCollection('uses').all())
|
||||||
|
|
||||||
const hardware = items.value!.filter(item => item.category === 'hardware')
|
const hardware = items.value!.filter(item => item.category === 'hardware')
|
||||||
const software = items.value!.filter(item => item.category === 'software')
|
const software = items.value!.filter(item => item.category === 'software')
|
||||||
|
|||||||
34
content.config.ts
Normal file
34
content.config.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { defineCollection, z } from '@nuxt/content'
|
||||||
|
|
||||||
|
export const collections = {
|
||||||
|
main: defineCollection({
|
||||||
|
type: 'page',
|
||||||
|
source: 'home/*.md',
|
||||||
|
}),
|
||||||
|
portfolio: defineCollection({
|
||||||
|
type: 'page',
|
||||||
|
source: 'portfolio/*.md',
|
||||||
|
schema: z.object({
|
||||||
|
slug: z.string(),
|
||||||
|
title: z.string(),
|
||||||
|
description: z.string(),
|
||||||
|
publishedAt: z.date(),
|
||||||
|
readingTime: z.number(),
|
||||||
|
cover: z.string(),
|
||||||
|
tags: z.array(z.string()),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
uses: defineCollection({
|
||||||
|
type: 'data',
|
||||||
|
source: 'uses/*.json',
|
||||||
|
schema: z.object({
|
||||||
|
name: z.string(),
|
||||||
|
description: z.object({
|
||||||
|
en: z.string(),
|
||||||
|
fr: z.string(),
|
||||||
|
es: z.string(),
|
||||||
|
}),
|
||||||
|
category: z.string(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}
|
||||||
@@ -10,6 +10,15 @@ tags:
|
|||||||
- maths
|
- maths
|
||||||
---
|
---
|
||||||
|
|
||||||
|
::UAlert
|
||||||
|
---
|
||||||
|
icon: i-ph-warning-duotone
|
||||||
|
color: amber
|
||||||
|
variant: soft
|
||||||
|
title: The Latex format may be not well rendered in the article, please refresh the page if you encounter any issue.
|
||||||
|
---
|
||||||
|
::
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
Machine Learning (ML) is a key discipline in artificial intelligence (AI), enabling systems to learn from data to make predictions or discover patterns. It is the driving force behind many modern innovations, from personalised recommendations to autonomous vehicles.
|
Machine Learning (ML) is a key discipline in artificial intelligence (AI), enabling systems to learn from data to make predictions or discover patterns. It is the driving force behind many modern innovations, from personalised recommendations to autonomous vehicles.
|
||||||
|
|||||||
@@ -34,14 +34,18 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
// Nuxt Content
|
// Nuxt Content
|
||||||
content: {
|
content: {
|
||||||
highlight: {
|
build: {
|
||||||
theme: 'github-dark',
|
markdown: {
|
||||||
},
|
highlight: {
|
||||||
markdown: {
|
theme: 'github-dark',
|
||||||
remarkPlugins: ['remark-math'],
|
},
|
||||||
rehypePlugins: {
|
remarkPlugins: {
|
||||||
'rehype-katex': {
|
'remark-math': {},
|
||||||
output: 'mathml',
|
},
|
||||||
|
rehypePlugins: {
|
||||||
|
'rehype-katex': {
|
||||||
|
output: 'mathml',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
"db:generate": "drizzle-kit generate"
|
"db:generate": "drizzle-kit generate"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/content": "^2.13.4",
|
"@nuxt/content": "3.0.0-alpha.7",
|
||||||
"@nuxt/image": "^1.8.1",
|
"@nuxt/image": "^1.8.1",
|
||||||
"@nuxt/ui": "^2.18.5",
|
"@nuxt/ui": "^2.18.5",
|
||||||
"@nuxthq/studio": "^2.1.1",
|
"@nuxthq/studio": "^2.1.1",
|
||||||
|
|||||||
608
pnpm-lock.yaml
generated
608
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user