diff --git a/src/layouts/Markdown.astro b/src/layouts/Markdown.astro
index 6968d0c..6c403ae 100644
--- a/src/layouts/Markdown.astro
+++ b/src/layouts/Markdown.astro
@@ -1,5 +1,6 @@
---
-import { getMonth, getDaySuffix } from "../utils";
+import { getMonth, getDaySuffix, getTagsBySlug } from "../utils";
+import Layout from "./Layout.astro";
import HomeButton from "../components/HomeButton.astro";
interface Props {
@@ -9,66 +10,88 @@ interface Props {
base: string,
}
-const { post, prev, next, base } = Astro.props;
+const { post, prev, next } = Astro.props;
+// 183 average w/p
+const readTime = `${Math.ceil(post.body.split(" ").length / 183)} min read`;
const date = new Date(post.data.pubDate);
+const tags = await getTagsBySlug(post.data.tags);
---
-
+
+
-
-
- Source
-
-
+
+
+ Source Code
+
+
-
-
-
-
-
-
-{(prev || next) && (
)}
-
-
-
+
+
diff --git a/src/pages/projects/[...slug].astro b/src/pages/projects/[...slug].astro
deleted file mode 100644
index 9c1fd79..0000000
--- a/src/pages/projects/[...slug].astro
+++ /dev/null
@@ -1,28 +0,0 @@
----
-import { getPosts } from "../../utils";
-import Layout from "../../layouts/Layout.astro";
-import Markdown from "../../layouts/Markdown.astro";
-
-export async function getStaticPaths() {
- const collection = await getPosts("projects");
-
- return collection.map((post, i) => ({
- params: { slug: post.slug },
- props: {
- post: post,
- prev: i > 0 ? collection[i - 1] : undefined,
- next: i < collection.length - 1 ? collection[i + 1] : undefined
- }
- }));
-}
-
-const { post, prev, next } = Astro.props;
-
-const { Content } = await post.render();
----
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro
deleted file mode 100644
index b273372..0000000
--- a/src/pages/projects/index.astro
+++ /dev/null
@@ -1,25 +0,0 @@
----
-import { getPosts } from "../../utils";
-import Layout from "../../layouts/Layout.astro";
-import Card from "../../components/Card.astro";
-import HomeButton from "../../components/HomeButton.astro";
-
-const projects = await getPosts("projects");
----
-
-
-
-
-
-
-
-
-
- {projects.map(post => (
-
- ))}
-
-
diff --git a/src/pages/search/[filter].astro b/src/pages/search/[filter].astro
new file mode 100644
index 0000000..a51efe4
--- /dev/null
+++ b/src/pages/search/[filter].astro
@@ -0,0 +1,70 @@
+---
+import { getCollection } from "astro:content";
+
+import { getPosts } from "../../utils";
+import Layout from "../../layouts/Layout.astro";
+import Card from "../../components/Card.astro";
+import HomeButton from "../../components/HomeButton.astro";
+
+export async function getStaticPaths() {
+ const collection = await getCollection("tags");
+
+ // Filter by file name, such as linux-kernel instead of "Linux Kernel"
+ return collection.map((tag) => ({
+ params: { filter: tag.slug },
+ props: { tag }
+ }));
+}
+
+const { tag } = Astro.props;
+
+const allPosts = await getPosts("posts");
+const filteredPosts = allPosts.filter((project) => project.data.tags.includes(tag.slug));
+---
+
+
+
+
+
+ Reset Filters
+
+
+
+
+
+
+
+
+
+
+ {filteredPosts.map(post => (
+
+ ))}
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages/search/index.astro b/src/pages/search/index.astro
new file mode 100644
index 0000000..6ad2dfe
--- /dev/null
+++ b/src/pages/search/index.astro
@@ -0,0 +1,36 @@
+---
+import { getCollection} from "astro:content";
+
+import { getPosts } from "../../utils";
+import Layout from "../../layouts/Layout.astro";
+import HomeButton from "../../components/HomeButton.astro";
+
+const tags = await getCollection("tags");
+const posts = await getPosts("posts");
+tags.forEach((tag) => {
+ tag.data.postCount = posts.filter((project) => {
+ return project.data.tags.includes(tag.slug);
+ }).length;
+})
+---
+
+
+
+
+
+
+
+
+
+
diff --git a/src/styles/_button.scss b/src/styles/_button.scss
index c835cb2..379c6b1 100644
--- a/src/styles/_button.scss
+++ b/src/styles/_button.scss
@@ -13,6 +13,7 @@
gap: 8px;
font-size: 14px;
+ font-weight: 500;
text-decoration: none;
border-radius: 9999px;
diff --git a/src/utils.ts b/src/utils.ts
index 223c530..117f428 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,4 +1,4 @@
-import { type ContentEntryMap, getCollection } from "astro:content";
+import {type CollectionEntry, type ContentEntryMap, getCollection} from "astro:content";
// https://github.com/hellotham/hello-astro/blob/e05706cf488bcec6e4c5494a622eedfc4e47d763/src/config.ts#L55C1-L62C2
export async function getPosts(collection: keyof ContentEntryMap) {
@@ -43,3 +43,14 @@ export function getDaySuffix(date: Date): string {
return suffix;
}
+
+export async function getTagsBySlug(postTags: string[]): Promise
[]> {
+ const allTags: CollectionEntry<"tags">[] = await getCollection("tags");
+ const tags: CollectionEntry<"tags">[] = [];
+ postTags.forEach((postTag) => {
+ allTags.forEach((allTag) => {
+ if (allTag.slug == postTag) tags.push(allTag);
+ });
+ });
+ return tags;
+}
\ No newline at end of file