Files
kazoottt-blog/src/pages/categories/index.astro
2024-07-21 22:29:07 +08:00

73 lines
2.0 KiB
Plaintext

---
import Button from '@/components/Button.astro'
import PageLayout from '@/layouts/BaseLayout.astro'
import { getAllPosts, getUniqueCategoriesWithCount } from '@/utils'
const allPosts = await getAllPosts()
const allCategories = getUniqueCategoriesWithCount(allPosts)
const meta = {
description: "A list of all the topics I've written about in my posts",
title: 'All Categories'
}
---
<PageLayout meta={meta}>
<div class='w-full'>
<Button title='Back' href='/blog' style='button'>
<svg
xmlns='http://www.w3.org/2000/svg'
width='14'
height='14'
viewBox='0 0 24 24'
slot='icon-before'
>
<path
fill='currentColor'
d='m6.921 12.5l5.792 5.792L12 19l-7-7l7-7l.713.708L6.921 11.5H19v1z'
>
</path>
</svg>
</Button>
<h1 class='mb-6 mt-5 text-2xl font-bold'>Categories</h1>
{allCategories.length === 0 && <p>No posts yet.</p>}
{
allCategories.length > 0 && (
<ul class='flex flex-col gap-y-3'>
{allCategories.map(([tag, val]) => (
<li class='flex items-center gap-x-2 '>
<a
class='inline-block underline underline-offset-4 hover:text-foreground/75'
data-astro-prefetch
href={`/tags/${tag}/`}
title={`View posts with the tag: ${tag}`}
>
&#35;{tag}
</a>
<span class='inline-block'>
- {val} post{val > 1 && 's'}
</span>
</li>
))}
</ul>
)
}
<a
href='https://github.com/srleom/astro-theme-resume.git'
class='mt-16 inline-flex flex-row items-center gap-x-3 rounded-3xl border border-input px-4 py-2 text-sm shadow-sm transition-all hover:shadow-md'
>
<span class='relative flex items-center justify-center'>
<span
class='absolute inline-flex h-2 w-2 animate-ping rounded-full border border-green-400 bg-green-400 opacity-75'
></span>
<span class='relative inline-flex h-2 w-2 rounded-full bg-green-400'></span>
</span>
<p class='font-medium'>Get free template</p>
</a>
</div>
</PageLayout>