diff --git a/components/ArticleBlock.tsx b/components/ArticleBlock.tsx index 8affe29..76ec546 100644 --- a/components/ArticleBlock.tsx +++ b/components/ArticleBlock.tsx @@ -2,13 +2,14 @@ import React from "react"; import { format } from "date-fns"; import Link from "next/link"; import { CalendarIcon } from "./icons/CalendarIcon"; +import { Tag } from "@components/Tag"; interface ArticleBlockProps { slug: string; title: string; description?: string; date: string; - tags?: string[]; + tags: string[]; } export default function ArticleBlock({ @@ -25,8 +26,17 @@ export default function ArticleBlock({

{title}

{description}

- {formattedDate} - + {tags.length != 0 ? ( +
+ {tags?.map((tag) => ( + {tag} + ))} +
+ ) : null} + + + {formattedDate} + ); } diff --git a/components/Tag.tsx b/components/Tag.tsx new file mode 100644 index 0000000..ee2f8d1 --- /dev/null +++ b/components/Tag.tsx @@ -0,0 +1,9 @@ +import Link from "next/link"; +import { slug } from "github-slugger"; + +interface TagProps { + children: string; +} +export function Tag({ children }: TagProps) { + return {children}; +} diff --git a/styles/components/_index.scss b/styles/components/_index.scss index ccada6e..298793d 100644 --- a/styles/components/_index.scss +++ b/styles/components/_index.scss @@ -7,4 +7,5 @@ @forward "toc-links"; @forward "info-box"; @forward "recipe-info"; -@forward "article-block"; \ No newline at end of file +@forward "article-block"; +@forward "tag"; \ No newline at end of file diff --git a/styles/components/_tag.scss b/styles/components/_tag.scss new file mode 100644 index 0000000..02723cd --- /dev/null +++ b/styles/components/_tag.scss @@ -0,0 +1,21 @@ +@use "../abstracts" as *; + +.tags { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; +} + +.tag { + cursor: pointer; + font-family: $font-bold; + font-size: 0.8rem; + display: inline-block; + padding: 0.25em 0.8em; + border-radius: 0.7em; + background-color: var(--collapsible-bg); + + &:hover { + background-color: var(--collapsible-summary-bg); + } +} diff --git a/velite.config.ts b/velite.config.ts index ef20c13..bdca3d8 100644 --- a/velite.config.ts +++ b/velite.config.ts @@ -64,7 +64,7 @@ const posts = defineCollection({ description: s.string().max(200).optional(), date: s.isodate(), published: s.boolean().default(true), - tags: s.array(s.string()).optional(), + tags: s.array(s.string()).default([]), body: s.mdx(), }) .transform(postComputedFields),