|
| 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> |
0 commit comments