Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Jan 13, 2025
1 parent 41ab948 commit c0c9734
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 49 deletions.
2 changes: 1 addition & 1 deletion app/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { locale } = useI18n()
>
<Body>
<LayoutScrollToTop />
<!-- <FolioMeta /> -->
<FolioMeta />
<NuxtLayout>
<UApp :locale="locales[locale]">
<NuxtPage />
Expand Down
2 changes: 1 addition & 1 deletion app/assets/style/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ html, body, #__nuxt, #__layout {
}

.writing {
@apply antialiased font-geist text-neutral-700/90 dark:text-neutral-400/80 leading-relaxed;
@apply font-geist text-neutral-700/90 dark:text-neutral-300 leading-relaxed;

h1 {
@apply text-2xl sm:text-3xl text-zinc-900 dark:text-zinc-100 italic font-[600] mb-6 mt-8;
Expand Down
11 changes: 3 additions & 8 deletions app/components/content/Works.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<script setup lang="ts">
import { withLeadingSlash } from 'ufo'
import type { Collections } from '@nuxt/content'
const route = useRoute()
const { locale } = useI18n()
const slug = computed(() => withLeadingSlash(String(route.params.slug)))
const { data: projects } = await useAsyncData('projects-' + slug.value, async () => {
const collection = ('projects_' + locale.value) as keyof Collections
return await queryCollection(collection).path(slug.value).first()
const { data: projects } = await useAsyncData('projects', async () => {
const collection = ('projects_' + locale.value)
return await queryCollection(collection).all()
}, {
watch: [locale],
})
Expand Down
20 changes: 10 additions & 10 deletions app/components/content/Writing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ const route = useRoute()
const { locale } = useI18n()
const slug = computed(() => withLeadingSlash(String(route.params.slug)))
const { data } = await useAsyncData('articles-' + slug.value, async () => {
const { data: articles } = await useAsyncData('articles-' + slug.value, async () => {
const collection = ('articles_' + locale.value) as keyof Collections
return await queryCollection(collection).path(slug.value).first()
return await queryCollection(collection).all()
}, {
watch: [locale],
})
console.log(articles.value)
if (!data.value)
if (!articles.value)
throw createError({ statusCode: 404, statusMessage: 'Page not found' })
const articles = computed(() => data.value)
/* const tags = computed(() =>
const tags = computed(() =>
Array.from(new Set(articles.value.flatMap(article => article.tags))),
) */
)
const filteredArticles = computed(() =>
articles.value.filter(article =>
Expand Down Expand Up @@ -73,7 +73,7 @@ const toggleTag = (tag: string) => {
:placeholder="$t('writing.search_article')"
/>
</div>
<!-- <div
<div
v-if="tags.length > 0"
class="mb-4 flex flex-wrap gap-2"
>
Expand All @@ -88,7 +88,7 @@ const toggleTag = (tag: string) => {
{{ tag }}
</div>
</div>
</div> -->
</div>
</div>
<TransitionGroup
v-if="filteredArticles.length"
Expand All @@ -98,13 +98,13 @@ const toggleTag = (tag: string) => {
>
<li
v-for="article of filteredArticles"
:key="article._path"
:key="article.path"
>
<ArticleCard
:title="article.title!"
:date="article.date"
:image="article.image"
:path="article._path!"
:path="article.path"
/>
</li>
</TransitionGroup>
Expand Down
8 changes: 7 additions & 1 deletion app/components/home/Projects.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<script setup lang="ts">
import type { Collections } from '@nuxt/content'
const { locale } = useI18n()
const { data: projects } = await useAsyncData('projects', () => queryContent('/projects').locale(locale.value).sort({ release: -1 }).find(), {
const { data: projects } = await useAsyncData('projects', async () => {
const collection = ('projects_' + locale.value) as keyof Collections
return await queryCollection(collection).all()
}, {
watch: [locale],
})
console.log(projects.value)
</script>

<template>
Expand Down
23 changes: 7 additions & 16 deletions app/components/project/Card.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script setup lang="ts">
import type { PropType } from 'vue'
import type { Project } from '~/data/projects'
defineProps({
defineProps<{
project: {
type: Object as PropType<Project>,
required: true,
},
})
name: string
release: string
image: string
link: string
}
}>()
const img = useImage()
</script>

Expand Down Expand Up @@ -37,14 +36,6 @@ const img = useImage()
<div class="rounded-t-lg border-x border-t border-white/10 border-b-transparent px-4 py-[5px] shadow-md backdrop-blur-md sm:w-2/3">
<div class="flex items-center justify-between gap-2">
<div class="flex items-center gap-2">
<component
:is="project.logo"
v-if="project.name !== 'Sekoïa'"
:alt="project.name + ' logo'"
:aria-label="project.name + ' logo'"
:font-controlled="false"
class="size-5 text-white/90"
/>
<div class="flex items-center gap-2">
<span class="whitespace-nowrap text-sm font-semibold text-white/90">
{{ project.name }}
Expand Down
21 changes: 14 additions & 7 deletions app/pages/articles/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<script lang="ts" setup>
const { t, locale } = useI18n()
import type { Collections } from '@nuxt/content'
const route = useRoute()
const { locale, t, localeProperties } = useI18n()
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).locale(locale.value).findOne(), {
const { data: page } = await useAsyncData(route.path, async () => {
const collection = ('articles_' + locale.value) as keyof Collections
return await queryCollection(collection).path(route.path).first()
}, {
watch: [locale],
})
if (!page.value) throw createError({ statusCode: 404, statusMessage: 'Page not found' })
useContentHead(page.value)
if (!page.value)
throw createError({ statusCode: 404, statusMessage: 'Page not found' })
const { copy } = useClipboard()
Expand Down Expand Up @@ -65,14 +68,18 @@ defineOgImage({
:shortcuts="['⌘', 'K']"
>
<p
class="flex cursor-pointer select-none items-center gap-1 transition-colors duration-200"
class="flex cursor-pointer select-none items-center gap-1 transition-colors duration-200 hover:text-primary"
@click="copyArticleLink"
>
{{ $t("writing.share") }}
</p>
</UTooltip>
</div>
<ContentRenderer :value="page" />
<ContentRenderer
v-if="page"
:dir="localeProperties?.dir ?? 'ltr'"
:value="page"
/>
</article>
</div>
</template>
Expand Down
24 changes: 20 additions & 4 deletions content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ const commonContentSchema = z.object({
date: z.string().nonempty(),
})

const commonArticleSchema = z.object({
title: z.string().nonempty(),
description: z.string().nonempty(),
date: z.string().nonempty(),
image: z.string().url(),
readingTime: z.string().nonempty(),
tags: z.array(z.string().nonempty()),
})

const commonProjectSchema = z.object({
name: z.string().nonempty(),
image: z.string().url(),
link: z.string().url(),
release: z.string().nonempty(),
date: z.string().nonempty(),
featured: z.boolean(),
})

const commonFaqSchema = z.object({
Expand Down Expand Up @@ -49,13 +59,19 @@ export const collections = {
}),
articles_en: defineCollection({
type: 'page',
source: 'en/articles/*.md',
schema: commonContentSchema,
source: {
include: 'en/articles/*.md',
prefix: '/articles',
},
schema: commonArticleSchema,
}),
articles_fr: defineCollection({
type: 'page',
source: 'fr/articles/*.md',
schema: commonContentSchema,
source: {
include: 'fr/articles/*.md',
prefix: '/articles',
},
schema: commonArticleSchema,
}),
projects_en: defineCollection({
type: 'data',
Expand Down
5 changes: 4 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export default defineNuxtConfig({
},

content: {
renderer: {
anchorLinks: false,
},
studio: {
enabled: true,
dev: true,
Expand Down Expand Up @@ -89,7 +92,7 @@ export default defineNuxtConfig({
{ code: 'en', name: 'English', language: 'en-US', dir: 'ltr' },
{ code: 'fr', name: 'French', language: 'fr-FR' },
],
strategy: 'no_prefix',
strategy: 'prefix_except_default',
defaultLocale: 'en',
vueI18n: '~/i18n.config.ts',
},
Expand Down

0 comments on commit c0c9734

Please sign in to comment.