diff --git a/src/components/layout/Header.astro b/src/components/layout/Header.astro
index fa9966e..7a7fbce 100644
--- a/src/components/layout/Header.astro
+++ b/src/components/layout/Header.astro
@@ -7,18 +7,42 @@
class='relative mx-auto flex w-full items-center justify-between sm:flex sm:items-center'
aria-label='global'
>
- resume
+ KazooTTT Blog
Blog
+
Categories
+
+
Tags
+
Tools
diff --git a/src/content/config.ts b/src/content/config.ts
index fe9555c..779c026 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -12,7 +12,7 @@ const post = defineCollection({
schema: ({ image }) =>
z.object({
title: z.string().max(60),
- description: z.string().min(50).max(160),
+ description: z.string(),
publishDate: z
.string()
.or(z.date())
@@ -29,7 +29,8 @@ const post = defineCollection({
.optional(),
draft: z.boolean().default(false),
tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase),
- ogImage: z.string().optional()
+ ogImage: z.string().optional(),
+ category: z.string().optional(),
})
})
diff --git a/src/content/post/cover-image/index.md b/src/content/post/cover-image/index.md
index 4f78dc9..7af5c5d 100644
--- a/src/content/post/cover-image/index.md
+++ b/src/content/post/cover-image/index.md
@@ -7,4 +7,5 @@ coverImage:
src: "./cover.png"
alt: "Astro build wallpaper"
tags: ["test", "image"]
+category: c1
---
diff --git a/src/content/post/draft-post.md b/src/content/post/draft-post.md
index 8517240..1215e7a 100644
--- a/src/content/post/draft-post.md
+++ b/src/content/post/draft-post.md
@@ -4,6 +4,7 @@ description: "This post is for testing the draft post functionality"
publishDate: "10 Sept 2023"
tags: ["test"]
draft: true
+category: c2
---
If this is working correctly, this post should only be accessible in a dev environment, as well as any tags that are unique to this post.
diff --git a/src/content/post/long-title.md b/src/content/post/long-title.md
index f79f330..d22020f 100644
--- a/src/content/post/long-title.md
+++ b/src/content/post/long-title.md
@@ -3,6 +3,7 @@ title: "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Id"
description: "This post is purely for testing if the css is correct for the title on the page"
publishDate: "01 Feb 2023"
tags: ["test"]
+category: c3
---
## Testing the title tag
diff --git a/src/pages/blog/[...page].astro b/src/pages/blog/[...page].astro
index 641f644..defcdf5 100644
--- a/src/pages/blog/[...page].astro
+++ b/src/pages/blog/[...page].astro
@@ -8,21 +8,23 @@ import Button from '@/components/Button.astro'
import Pagination from '@/components/Paginator.astro'
import PostPreview from '@/components/blog/PostPreview.astro'
import PageLayout from '@/layouts/BaseLayout.astro'
-import { getAllPosts, getUniqueTags, sortMDByDate } from '@/utils'
+import { getAllPosts, getUniqueCategories, getUniqueTags, sortMDByDate } from '@/utils'
export const getStaticPaths = (async ({ paginate }) => {
const allPosts = await getAllPosts()
const allPostsByDate = sortMDByDate(allPosts)
const uniqueTags = getUniqueTags(allPosts)
- return paginate(allPostsByDate, { pageSize: 10, props: { uniqueTags } })
+ const uniqueCategories = getUniqueCategories(allPosts)
+ return paginate(allPostsByDate, { pageSize: 10, props: { uniqueTags, uniqueCategories } })
}) satisfies GetStaticPaths
interface Props {
page: Page
>
uniqueTags: string[]
+ uniqueCategories: string[]
}
-const { page, uniqueTags } = Astro.props
+const { page, uniqueTags, uniqueCategories } = Astro.props
const meta = {
description: 'Posts',
@@ -77,41 +79,89 @@ const paginationProps = {
- {!!uniqueTags.length && (
-
-
-
-
-
-
-
-
- Tags
-
-
- {uniqueTags.map((tag) => (
-
-
-
- ))}
-
-
-
- View all →
-
-
-
- )}
+
+ {!!uniqueCategories.length && (
+
+
+
+
+
+
+
+
+ Categories
+
+
+ {uniqueCategories.slice(0, 6).map((category) => (
+
+
+
+ ))}
+
+
+
+ View all →
+
+
+
+ )}
+
+ {!!uniqueTags.length && (
+
+
+
+
+
+
+
+
+ Tags
+
+
+ {uniqueTags.slice(0, 6).map((tag) => (
+
+
+
+ ))}
+
+
+
+ View all →
+
+
+
+ )}
+
)
}
diff --git a/src/pages/categories/[category]/[...page].astro b/src/pages/categories/[category]/[...page].astro
new file mode 100644
index 0000000..4971476
--- /dev/null
+++ b/src/pages/categories/[category]/[...page].astro
@@ -0,0 +1,96 @@
+---
+export const prerender = true
+
+import type { GetStaticPaths, Page } from 'astro'
+import type { CollectionEntry } from 'astro:content'
+
+import Pagination from '@/components/Paginator.astro'
+import PostPreview from '@/components/blog/PostPreview.astro'
+import PageLayout from '@/layouts/BaseLayout.astro'
+import Button from '@/components/Button.astro'
+import { getAllPosts, getUniqueTags, sortMDByDate } from '@/utils'
+
+export const getStaticPaths: GetStaticPaths = async ({ paginate }) => {
+ const allPosts = await getAllPosts()
+ const allPostsByDate = sortMDByDate(allPosts)
+ const uniqueTags = getUniqueTags(allPostsByDate)
+
+ return uniqueTags.flatMap((tag) => {
+ const filterPosts = allPostsByDate.filter((post) => post.data.tags.includes(tag))
+ return paginate(filterPosts, {
+ pageSize: 10,
+ params: { tag }
+ })
+ })
+}
+
+interface Props {
+ page: Page