+
+
-
-
-
diff --git a/src/layouts/DefaultLayout/Header.astro b/src/layouts/DefaultLayout/Header.astro
index 97d2b96..77a4a83 100644
--- a/src/layouts/DefaultLayout/Header.astro
+++ b/src/layouts/DefaultLayout/Header.astro
@@ -3,14 +3,15 @@ import karin from '~/assets/karin.gif'
import { Link } from '../../components/ui/Link.tsx'
const PAGES = [
- { name: 'hewwo', path: '/' },
- { name: 'donate', path: ['/donate', '/$'] },
+ { name: 'hewwo', path: '/', match: /^\/$/ },
+ { name: 'blog', path: '/blog', match: /^\/blog(\/|$)/ },
+ { name: 'donate', path: '/donate', match: /^\/(donate|\$)\/?$/ },
]
---
@@ -24,16 +25,11 @@ const PAGES = [
)
}
- let isActive
- if (Array.isArray(page.path)) {
- isActive = page.path.includes(Astro.url.pathname)
- } else {
- isActive = Astro.url.pathname === page.path
- }
+ const isActive = page.match.test(Astro.url.pathname)
if (isActive) {
elements.push(
- {page.name},
+ {page.name},
)
} else {
const href = Array.isArray(page.path) ? page.path[0] : page.path
diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro
new file mode 100644
index 0000000..ef79c9f
--- /dev/null
+++ b/src/pages/blog/[slug].astro
@@ -0,0 +1,176 @@
+---
+import { getCollection, render } from 'astro:content'
+
+import DefaultLayout from '../../layouts/DefaultLayout/DefaultLayout.astro'
+
+export const prerender = true
+
+export async function getStaticPaths() {
+ const posts = await getCollection('blog')
+ return posts.map(post => ({
+ params: { slug: post.id },
+ props: { post },
+ }))
+}
+
+const { post } = Astro.props
+const { Content, remarkPluginFrontmatter } = await render(post);
+---
+
+
+
+
+
{post.data.title}
+
+ {post.data.date.toLocaleString('en-US', {
+ month: 'long',
+ day: 'numeric',
+ year: 'numeric',
+ }).toLowerCase()}
+ //
+ {remarkPluginFrontmatter.minutesRead}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro
new file mode 100644
index 0000000..33310cd
--- /dev/null
+++ b/src/pages/blog/index.astro
@@ -0,0 +1,51 @@
+---
+import { parallelMap } from '@fuman/utils'
+
+import { getCollection, render } from 'astro:content'
+import { Link } from '../../components/ui/Link.tsx'
+import { sortPostsByDateReverse } from '../../content.config.ts'
+import DefaultLayout from '../../layouts/DefaultLayout/DefaultLayout.astro'
+import { Button } from '../../components/ui/Button.tsx'
+
+export const prerender = true
+
+const posts = (await getCollection('blog')).sort(sortPostsByDateReverse)
+const postsRendered = await parallelMap(posts, async post => ({
+ post,
+ rendered: await render(post),
+}))
+---
+
+
+
+
+ {postsRendered.map(({ post, rendered }) => (
+
+
+ {post.data.title}
+
+
+
+ //
+ {rendered.remarkPluginFrontmatter.minutesRead}
+
+
+ {post.data.description}
+
+
+ ))}
+
diff --git a/uno.config.ts b/uno.config.ts
index 763b1b8..20d9515 100644
--- a/uno.config.ts
+++ b/uno.config.ts
@@ -1,10 +1,13 @@
-import { defineConfig, presetIcons, presetUno } from 'unocss'
+import { defineConfig, presetIcons, presetUno, transformerVariantGroup } from 'unocss'
export default defineConfig({
presets: [
presetUno(),
presetIcons(),
],
+ transformers: [
+ transformerVariantGroup(),
+ ],
shortcuts: {
'content-dblslash': [
{ content: '"//"' },