From a341ae4b31ff3e77a96fa1a7eeed1cc9deff5ed9 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 15 Jul 2024 16:49:31 +0200 Subject: [PATCH 1/2] feat: update content config --- src/content/config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/content/config.ts b/src/content/config.ts index 7ac4a25..61c6bf7 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -52,7 +52,15 @@ const resourcesSchema = defineCollection({ }), }); +export const tagsSchema = defineCollection({ + type: 'data', + schema: z.object({ + title: z.string() + }) +}) + export const collections = { docs: starlightSchema, resources: resourcesSchema, + tags: tagsSchema }; From ce5ad46969a712b3fcf9623bba4f451490bc9831 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Mon, 15 Jul 2024 16:58:40 +0200 Subject: [PATCH 2/2] feat: whatever --- src/components/Tags.astro | 21 +++++++++------------ src/content/config.ts | 4 ++-- src/content/tags/3rd-party.json | 3 +++ src/content/tags/animation.json | 3 +++ src/content/tags/auth.json | 3 +++ src/content/tags/css.json | 3 +++ src/content/tags/db.json | 3 +++ src/content/tags/deploy.json | 3 +++ src/content/tags/editor.json | 3 +++ src/content/tags/i18n.json | 3 +++ src/content/tags/images.json | 3 +++ src/content/tags/markdown.json | 3 +++ src/content/tags/migration.json | 3 +++ src/content/tags/performance.json | 3 +++ src/content/tags/rss.json | 3 +++ src/content/tags/utilities.json | 3 +++ src/content/tags/view-transitions.json | 3 +++ 17 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 src/content/tags/3rd-party.json create mode 100644 src/content/tags/animation.json create mode 100644 src/content/tags/auth.json create mode 100644 src/content/tags/css.json create mode 100644 src/content/tags/db.json create mode 100644 src/content/tags/deploy.json create mode 100644 src/content/tags/editor.json create mode 100644 src/content/tags/i18n.json create mode 100644 src/content/tags/images.json create mode 100644 src/content/tags/markdown.json create mode 100644 src/content/tags/migration.json create mode 100644 src/content/tags/performance.json create mode 100644 src/content/tags/rss.json create mode 100644 src/content/tags/utilities.json create mode 100644 src/content/tags/view-transitions.json diff --git a/src/components/Tags.astro b/src/components/Tags.astro index 43bcef5..d943fc1 100644 --- a/src/components/Tags.astro +++ b/src/components/Tags.astro @@ -6,25 +6,22 @@ interface Props { tags?: string[]; } const allResources = await getCollection("resources"); +const allTags = await getCollection("tags") const tagsParams = Astro.url.searchParams.getAll("tag"); -// Set is used to remove duplicates -const allTags = Array.from( - new Set(allResources.flatMap((resource) => resource.data.tags ?? [])), -); const { tags } = Astro.props; // Determine which tags to display const filteredTags = tags && tags.length > 0 - ? allTags.filter((tag) => tags.includes(tag)) + ? allTags.filter((tag) => tags.includes(tag.id)) : allTags; const style = allTags .map( (tag) => - `.sl-markdown-content:has([data-tag=${JSON.stringify(tag)}]:checked) .card-wrapper[data-tags*=${JSON.stringify(tag)}] { display: block; }`, + `.sl-markdown-content:has([data-tag=${JSON.stringify(tag.id)}]:checked) .card-wrapper[data-tags*=${JSON.stringify(tag.id)}] { display: block; }`, ) .join("\n"); --- @@ -80,12 +77,12 @@ const style = allTags - + )) } @@ -96,7 +93,7 @@ const style = allTags { allResources.map((r) => ( -
+
t.id)}>