diff --git a/src/pages/blog/[...page].astro b/src/pages/blog/[...page].astro new file mode 100644 index 0000000..2fbb767 --- /dev/null +++ b/src/pages/blog/[...page].astro @@ -0,0 +1,61 @@ +--- +import Layout from "~/layouts/PageLayout.astro"; + +import { SITE } from "~/config.mjs"; +import { getAllPosts } from "~/utils/getAllPosts"; +import BlogPostCard from "~/components/widgets/BlogPostCard.astro"; +import Pagination from "~/components/widgets/Pagination.astro"; + +export async function getStaticPaths({ paginate }) { + const posts = await getAllPosts(); + + return paginate(posts, { + pageSize: SITE.postsPerPage, + }); +} + +const { page } = Astro.props; + +const currentPage = page.currentPage ?? 1; + +const title = `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${ + SITE.name +}`; +const description = "News and step-by-step guides about AstroWind"; +const canonical = new URL(page.url.current, Astro.site); +--- + + +
+
+
+

+ News and step-by-step guides about + AstroWind + +

+
+
    + { + page.data.map((post) => ( +
  • + +
  • + )) + } +
+ + { + (page.url.prev || page.url.next) && ( + + ) + } +
+
+
diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro new file mode 100644 index 0000000..fc84a6e --- /dev/null +++ b/src/pages/blog/[slug].astro @@ -0,0 +1,79 @@ +--- +import Layout from "~/layouts/PageLayout.astro"; +import Picture from "~/components/core/Picture.astro"; + +import { SITE } from "~/config.mjs"; +import { getAllPosts } from "~/utils/getAllPosts"; + +export async function getStaticPaths() { + const posts = await getAllPosts(); + + return posts.map((post) => ({ + params: { slug: post.slug }, + props: { post }, + })); +} + +const { post } = Astro.props; + +const title = `${post.title} — ${SITE.name}`; +const description = post.description; +const canonical = new URL(`blog/${post.slug}/`, Astro.site); + +const images = import.meta.glob("../../assets/images/*"); + +const imageSrc = + typeof images[post.image] === "function" + ? (await images[post.image]())["default"] + : typeof post.image === "string" + ? post.image + : null; +--- + + +
+
+
+
+

+ ~ {Math.ceil(post.readingTime)} min +

+

+ {post.title} +

+ + +
+
+ +
+
+
+
+