From 35a350e6e4921ff3fe662783a1d7735b671150ac Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Sun, 20 Jul 2025 19:09:13 +0200 Subject: [PATCH] Refactor project and writing components: simplify tag rendering and group writings by year --- app/pages/projects/index.vue | 7 +-- app/pages/writings/index.vue | 107 ++++++++++++++++++++--------------- types/index.ts | 14 ----- 3 files changed, 61 insertions(+), 67 deletions(-) diff --git a/app/pages/projects/index.vue b/app/pages/projects/index.vue index 76af390..b67c618 100644 --- a/app/pages/projects/index.vue +++ b/app/pages/projects/index.vue @@ -73,15 +73,10 @@ const { data: projects } = await useAsyncData('all-projects', () => { -
- -

{{ TAGS.find(color => color.label.toLowerCase() === tag)?.label }}

-
+ {{ TAGS.find(color => color.label.toLowerCase() === tag)?.label }}
diff --git a/app/pages/writings/index.vue b/app/pages/writings/index.vue index cb508fb..f88b42d 100644 --- a/app/pages/writings/index.vue +++ b/app/pages/writings/index.vue @@ -14,10 +14,23 @@ const { data: writings } = await useAsyncData('all-writings', () => { .order('publishedAt', 'DESC') .all() }) + +// Group writings by year +const groupedWritings = computed(() => { + const grouped: Record = {} + writings.value!.forEach((writing: any) => { + const year = new Date(writing.publishedAt).getFullYear().toString() + if (!grouped[year]) { + grouped[year] = [] + } + grouped[year].push(writing) + }) + return Object.entries(grouped).reverse() +}) diff --git a/types/index.ts b/types/index.ts index ce70dee..5c2d3b3 100644 --- a/types/index.ts +++ b/types/index.ts @@ -107,8 +107,6 @@ export const activityMessages = { export interface Tag { label: string - icon: string - color: string title?: string translation: string } @@ -116,38 +114,26 @@ export interface Tag { export const TAGS: Array = [ { label: 'R', - icon: 'i-vscode-icons-file-type-r', - color: 'orange', translation: 'tags.r', }, { label: 'AI', - icon: 'i-ph-brain-duotone', - color: 'green', translation: 'tags.ai', }, { label: 'Data', - icon: 'i-ph-database-duotone', - color: 'purple', translation: 'tags.data', }, { label: 'Web', - icon: 'i-ph-globe-duotone', - color: 'cyan', translation: 'tags.web', }, { label: 'Python', - icon: 'i-vscode-icons-file-type-python', - color: 'amber', translation: 'tags.python', }, { label: 'Maths', - icon: 'i-ph-calculator-duotone', - color: 'pink', translation: 'tags.maths', }, ]