25
site/src/components/BlogPostCard.astro
Normal file
25
site/src/components/BlogPostCard.astro
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
import type { WordpressPost } from "../lib/content/types";
|
||||
|
||||
type Props = {
|
||||
post: WordpressPost;
|
||||
};
|
||||
|
||||
const { post } = Astro.props;
|
||||
|
||||
function truncate(s: string, n: number) {
|
||||
if (!s) return "";
|
||||
const t = s.trim();
|
||||
if (t.length <= n) return t;
|
||||
return `${t.slice(0, Math.max(0, n - 1)).trimEnd()}…`;
|
||||
}
|
||||
---
|
||||
|
||||
<a class="blog-card" href={`/blog/post/${post.slug}`}>
|
||||
{post.featuredImageUrl ? <img src={post.featuredImageUrl} alt="" loading="lazy" /> : null}
|
||||
<div class="blog-card-body">
|
||||
<h3 class="blog-card-title">{post.title}</h3>
|
||||
<p class="blog-card-excerpt">{truncate(post.excerpt || "", 180)}</p>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
25
site/src/components/BlogSecondaryNav.astro
Normal file
25
site/src/components/BlogSecondaryNav.astro
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
import type { WordpressCategory } from "../lib/content/types";
|
||||
|
||||
type Props = {
|
||||
categories: WordpressCategory[];
|
||||
activeCategorySlug?: string;
|
||||
};
|
||||
|
||||
const { categories, activeCategorySlug } = Astro.props;
|
||||
---
|
||||
|
||||
<nav class="subnav" aria-label="Blog categories">
|
||||
<a class={!activeCategorySlug ? "active" : ""} href="/blog">
|
||||
All
|
||||
</a>
|
||||
<a class={activeCategorySlug === "__pages" ? "active" : ""} href="/blog/pages">
|
||||
Pages
|
||||
</a>
|
||||
{categories.map((c) => (
|
||||
<a class={activeCategorySlug === c.slug ? "active" : ""} href={`/blog/category/${c.slug}`}>
|
||||
{c.name}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user