Add Categories and Tags with new configs

This commit is contained in:
prototypa
2022-08-30 11:37:19 -04:00
parent 4859dcee87
commit 49c6c5611b
26 changed files with 434 additions and 217 deletions

View File

@ -0,0 +1,39 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
import { getCanonical, getPermalink } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled) return [];
const posts = await fetchPosts();
return paginate(posts, {
params: { blog: BLOG?.slug || undefined },
pageSize: BLOG.postsPerPage,
});
}
const { page } = Astro.props;
const currentPage = page.currentPage ?? 1;
const meta = {
title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name}`,
description: SITE.description,
canonical: getCanonical(getPermalink(page.url.current))
}
---
<Layout meta={meta}>
<Fragment slot="title">
News and step-by-step guides about
<span class="bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-pink-500">AstroWind
</span>
</Fragment>
<BlogList page={page} />
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</Layout>

View File

@ -0,0 +1,33 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { getCanonical, getPermalink } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/fetchPosts";
import { findImage } from "~/utils/findImage";
import Layout from "~/layouts/PageLayout.astro";
import BlogPost from "~/components/widgets/BlogPost.astro";
export async function getStaticPaths() {
if (BLOG?.disabled) return [];
const posts = await fetchPosts();
return posts.map((post) => ({
params: { slug: post.slug, blog: BLOG.postsWithoutBlogSlug ? undefined : BLOG?.slug || undefined },
props: { post },
}));
}
const { post } = Astro.props;
const meta = {
title: `${post.title} — ${SITE.name}`,
description: post.description,
canonical: post.canonical || getCanonical(getPermalink(post.slug, "post")),
image: await findImage(post.image),
}
---
<Layout meta={meta}>
<BlogPost post={{ ...post, image: meta.image }} />
</Layout>