diff --git a/src/components/blog/Tags.astro b/src/components/blog/Tags.astro
index 122cd91..710ef84 100644
--- a/src/components/blog/Tags.astro
+++ b/src/components/blog/Tags.astro
@@ -6,29 +6,36 @@ import type { Post } from '~/types';
export interface Props {
tags: Post['tags'];
- class?: string;
+ class?: string;
+ title?: string | undefined;
+ isCategory?: boolean;
}
-const { tags, class: className = 'text-sm' } = Astro.props;
+const { tags, class: className = 'text-sm', title = undefined, isCategory = false } = Astro.props;
---
{
tags && Array.isArray(tags) && (
-
- {tags.map((tag) => (
- -
- {BLOG?.tag?.disabled ? (
- tag
- ) : (
-
- {tag}
-
- )}
-
- ))}
-
+ <>
+ <>
+ {title !== undefined && {title}}
+ >
+
+ {tags.map((tag) => (
+ -
+ {BLOG?.tag?.disabled ? (
+ tag
+ ) : (
+
+ {tag}
+
+ )}
+
+ ))}
+
+ >
)
}
diff --git a/src/pages/[...blog]/[...page].astro b/src/pages/[...blog]/[...page].astro
index 25e057d..e602f29 100644
--- a/src/pages/[...blog]/[...page].astro
+++ b/src/pages/[...blog]/[...page].astro
@@ -5,8 +5,10 @@ import Layout from '~/layouts/PageLayout.astro';
import BlogList from '~/components/blog/List.astro';
import Headline from '~/components/blog/Headline.astro';
import Pagination from '~/components/blog/Pagination.astro';
+// import PostTags from "~/components/blog/Tags.astro";
import { fetchPosts } from '~/utils/blog';
+// import { findTags, findCategories } from '~/utils/blog';
import { BLOG_BASE } from '~/utils/permalinks';
export async function getStaticPaths({ paginate }) {
@@ -20,6 +22,9 @@ export async function getStaticPaths({ paginate }) {
const { page } = Astro.props;
const currentPage = page.currentPage ?? 1;
+// const allCategories = await findCategories();
+// const allTags = await findTags();
+
const meta = {
title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`,
description: SITE.description,
@@ -37,5 +42,9 @@ const meta = {
+
diff --git a/src/utils/blog.ts b/src/utils/blog.ts
index eab9735..97c1478 100644
--- a/src/utils/blog.ts
+++ b/src/utils/blog.ts
@@ -122,3 +122,27 @@ export const findLatestPosts = async ({ count }: { count?: number }): Promise> => {
+ const posts = await fetchPosts();
+ const tags = posts.reduce((acc, post: Post) => {
+ if (post.tags && Array.isArray(post.tags)) {
+ return [...acc, ...post.tags];
+ }
+ return acc;
+ }, []);
+ return [...new Set(tags)];
+};
+
+/** */
+export const findCategories = async (): Promise> => {
+ const posts = await fetchPosts();
+ const categories = posts.reduce((acc, post: Post) => {
+ if (post.category) {
+ return [...acc, post.category];
+ }
+ return acc;
+ }, []);
+ return [...new Set(categories)];
+};