diff --git a/src/pages/tags/[tag].astro b/src/pages/tags/[tag].astro new file mode 100644 index 0000000..e452c7c --- /dev/null +++ b/src/pages/tags/[tag].astro @@ -0,0 +1,60 @@ +--- +import Layout from "@layouts/Layout.astro"; +import Main from "@layouts/Main.astro"; +import Header from "@components/Header.astro"; +import Footer from "@components/Footer.astro"; +import Card from "@components/Card.astro"; +import type { MarkdownInstance } from "astro"; +import type { Frontmatter } from "@utils/types"; +import getUniqueTags from "@utils/getUniqueTags"; +import getPostsByTag from "@utils/getPostsByTag"; + +export interface Props { + post: MarkdownInstance; + tag: string; +} + +export async function getStaticPaths() { + const posts: MarkdownInstance[] = await Astro.glob( + "../../contents/*.md" + ); + + const tags = getUniqueTags(posts); + + return tags.map((tag) => { + return { + params: { + tag, + }, + props: { + tag, + }, + }; + }); +} + +const { tag } = Astro.props; + +const posts: MarkdownInstance[] = await Astro.glob( + "../../contents/*.md" +); + +const tagPosts = getPostsByTag(posts, tag); +--- + + +
+
+
    + { + tagPosts.map(({ frontmatter }) => ( + + )) + } +
+
+