diff options
author | Valentin Popov <valentin@popov.link> | 2025-06-10 17:20:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-10 17:20:48 +0300 |
commit | d74eec1c47a0d4da5c50b70da3fedbdef0cafcc6 (patch) | |
tree | affd620f3ea07a9054284b7baafbcd9bc33a1879 /src/pages | |
parent | d32248742050d59baf83c17a6c6566b3ecdf5614 (diff) | |
parent | 9ebcd40f60ffa393a56db850b6a6d0cf15ef4211 (diff) | |
download | popov.link-d74eec1c47a0d4da5c50b70da3fedbdef0cafcc6.tar.xz popov.link-d74eec1c47a0d4da5c50b70da3fedbdef0cafcc6.zip |
Merge pull request #48 from valentineus/header
New Header
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/[...page].astro | 33 | ||||
-rw-r--r-- | src/pages/blog/[...slug].astro | 10 | ||||
-rw-r--r-- | src/pages/blog/index.astro | 19 | ||||
-rw-r--r-- | src/pages/index.astro | 17 |
4 files changed, 40 insertions, 39 deletions
diff --git a/src/pages/[...page].astro b/src/pages/[...page].astro deleted file mode 100644 index 6d513b2..0000000 --- a/src/pages/[...page].astro +++ /dev/null @@ -1,33 +0,0 @@ ---- -import type { GetStaticPaths, InferGetStaticPropsType } from "astro"; -import { getCollection } from "astro:content"; -import Layout from "../layouts/BaseLayout.astro"; -import Pagination from "../components/Pagination.astro"; -import PostSummary from "../components/PostSummary.astro"; - -type Props = InferGetStaticPropsType<typeof getStaticPaths>; - -export const getStaticPaths = (async ({ paginate }) => { - const posts = await getCollection("blog", ({ data }) => { - return data.draft !== true; - }); - - posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime()); - - return paginate(posts, { - pageSize: 10, - }); -}) satisfies GetStaticPaths; - -const { page } = Astro.props; ---- - -<Layout> - <section style={{ "margin-top": "3rem" }}> - {page.data.map((post) => <PostSummary post={post} />)} - </section> - - <section> - <Pagination nextUrl={page.url.next} prevUrl={page.url.prev} /> - </section> -</Layout> diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 41b0f5c..c4e542c 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -33,10 +33,12 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY" <Layout description={post.data.description} title={post.data.title}> <article> <section> + <h1>{post.data.title}</h1> + </section> + + <section> <p> <small> - <a href="/">< Home</a> - <span> • </span> Posted <time datetime={post.data.pubDate.toISOString()}>{formattedDate}</time> by {post.data.author} @@ -47,10 +49,6 @@ const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY" </section> <section> - <h1>{post.data.title}</h1> - </section> - - <section> <Content /> </section> diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro new file mode 100644 index 0000000..48d33e8 --- /dev/null +++ b/src/pages/blog/index.astro @@ -0,0 +1,19 @@ +--- +import { getCollection } from "astro:content"; +import Layout from "../../layouts/BaseLayout.astro"; +import PostElement from "../../components/PostElement.astro"; + +const posts = await getCollection("blog", ({ data }) => { + return data.draft !== true; +}); + +posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime()); +--- + +<Layout> + <section style={{ "margin-top": "3rem" }}> + <ul> + {posts.map((post) => <PostElement post={post} />)} + </ul> + </section> +</Layout> diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..56ccdff --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,17 @@ +--- +import { getCollection } from "astro:content"; +import Layout from "../layouts/BaseLayout.astro"; +import PostSummary from "../components/PostSummary.astro"; + +const posts = await getCollection("blog", ({ data }) => { + return data.draft !== true; +}); + +posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime()); +--- + +<Layout> + <section style={{ "margin-top": "3rem" }}> + {posts.map((post) => <PostSummary post={post} />)} + </section> +</Layout> |