Skip to content

Commit 9692b1f

Browse files
committed
Add tags back
1 parent da5ce00 commit 9692b1f

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

src/components/Tag.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export type Props = {
66
const { tag } = Astro.props
77
88
---
9-
<a href={`/idea/tag/#${tag.toLowerCase()}`} class="px-2 text-sm rounded-full border-1 border-primary text-primary hover:bg-primary hover:text-primary-content">
9+
<a href={`/idea/tag/${tag.toLowerCase()}`} class="px-2 text-sm rounded-full border-1 border-primary text-primary hover:bg-primary hover:text-primary-content">
1010
# {tag.toLowerCase()}
1111
</a>

src/pages/about.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Layout from "@layouts/Layout.astro";
1111

1212
<span>The projects that make this site possible</span>
1313
<ul class="flex flex-row gap-0">
14+
<li class="btn btn-sm btn-ghost">
15+
<a href="https://github.com/oven-sh/bun">Bun</a></li>
1416
<li class="btn btn-sm btn-ghost ">
1517
<a href="https://github.com/withastro/astro">Astro</a></li>
1618
<li class="btn btn-sm btn-ghost ">

src/pages/idea/tag/[tag].astro

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
import Drawer from "@layouts/Drawer.astro";
3+
import Layout from "@layouts/Layout.astro";
4+
import { Idea } from "@tool/idea";
5+
import { getCollection } from "astro:content";
6+
import { Construction, Lightbulb } from "lucide-astro";
7+
8+
export async function getStaticPaths() {
9+
return (await getCollection("ideas")).reduce((tags, idea) => {
10+
idea.data.tags?.forEach(tag => {
11+
if(!tags.includes(tag)) tags.push(tag)
12+
})
13+
return tags
14+
}, new Array<string>).map(tag => ({
15+
params: { tag }
16+
}))
17+
}
18+
19+
const { tag } = Astro.params
20+
21+
const ideas = (await getCollection("ideas"))
22+
.filter(idea => idea.data.tags?.includes(tag))
23+
---
24+
25+
<Layout>
26+
<Drawer>
27+
<div class="flex flex-col w-full items-center">
28+
<div class="h-4"></div>
29+
<span class="text-6xl font-bold border-2 rounded-full px-4 py-2"># {tag}</span>
30+
<div class="h-4"></div>
31+
{ ideas.map(idea => (
32+
<a href={`/idea/${Idea.slug(idea)}`} class="flex flex-row items-center p-4 rounded-lg hover:bg-base-200">
33+
{ !Idea.isDraft(idea) && <Lightbulb class="w-10 h-10"/> }
34+
{ Idea.isDraft(idea) && <Construction class="w-10 h-10"/> }
35+
<div class="divider divider-horizontal"></div>
36+
<div class="flex flex-col flex-1 items-start">
37+
<span class="text-lg lg:text-xl font-bold">{idea.data.title }</span>
38+
<div class="text-sm lg:text-lg flex flex-row gap-1 ">
39+
{ idea.data.author && <span>{idea.data.author}</span>}
40+
{ (idea.data.author && idea.data.pubDate) && "|" }
41+
{ idea.data.pubDate && <span>{idea.data.pubDate?.toDateString()}</span>}
42+
</div>
43+
</div>
44+
</a>
45+
))}
46+
</div>
47+
</Drawer>
48+
</Layout>

src/pages/idea/tag/index.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<script>
2+
location.href=`/idea/tag/${location.hash.slice(2)}`
3+
</script>

src/pages/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ideas = (await getCollection("ideas"))
2626
<span class="text-xl italic text-center hidden sm:inline">Full-Time Dad, Part-Time DM, Some-Time Programmer</span>
2727
<div class="flex flex-row gap-1">
2828
<span class="tooltip tooltip-bottom" data-tip="Blog">
29-
<a class="btn btn-xl btn-ghost btn-circle" href="#idea">
29+
<a class="btn btn-xl btn-ghost btn-circle" href="#ideas">
3030
<LibraryBig class="w-10 h-10"/>
3131
</a>
3232
</span>
@@ -52,7 +52,7 @@ const ideas = (await getCollection("ideas"))
5252
</div>
5353
</div>
5454

55-
<a id="idea"></a>
55+
<a id="ideas"></a>
5656

5757
<div class="flex flex-col w-full min-h-dvh justify-center items-center">
5858
<span class="text-6xl text-center font-bold p-8">

0 commit comments

Comments
 (0)