aboutsummaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-09-05 00:16:37 +0300
committerValentin Popov <valentin@popov.link>2024-09-05 00:16:37 +0300
commit7eff3fde5720eb23449e2f8c8ea0b8218efe4dde (patch)
treefbaedd693902c1a6d56a005b28b189ef76fe23f4 /src/pages
parentecf9a15e77509d344ab4ee02ae0dbf8a116021f1 (diff)
downloadpopov.link-7eff3fde5720eb23449e2f8c8ea0b8218efe4dde.tar.xz
popov.link-7eff3fde5720eb23449e2f8c8ea0b8218efe4dde.zip
Initial Astro project
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/blog/[...slug].astro20
-rw-r--r--src/pages/index.astro18
2 files changed, 38 insertions, 0 deletions
diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro
new file mode 100644
index 0000000..c94fe52
--- /dev/null
+++ b/src/pages/blog/[...slug].astro
@@ -0,0 +1,20 @@
+---
+import { type CollectionEntry, getCollection } from "astro:content";
+import Layout from "../../layouts/PostLayout.astro";
+
+export async function getStaticPaths() {
+ const posts = await getCollection("blog");
+ return posts.map((post) => ({
+ params: { slug: post.slug },
+ props: post,
+ }));
+}
+type Props = CollectionEntry<"blog">;
+
+const post = Astro.props;
+const { Content } = await post.render();
+---
+
+<Layout>
+ <Content />
+</Layout>
diff --git a/src/pages/index.astro b/src/pages/index.astro
new file mode 100644
index 0000000..bc98c67
--- /dev/null
+++ b/src/pages/index.astro
@@ -0,0 +1,18 @@
+---
+import Layout from "../layouts/PageLayout.astro";
+import { getCollection } from "astro:content";
+
+const posts = await getCollection("blog");
+---
+
+<Layout>
+ <ul>
+ {
+ posts.map((post) => (
+ <li>
+ <a href={`/blog/${post.slug}`}>{post.data.title}</a>
+ </li>
+ ))
+ }
+ </ul>
+</Layout>