first commit

This commit is contained in:
Matt Kane
2026-04-01 10:44:22 +01:00
commit 43fcb9a131
1789 changed files with 395041 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
---
import { getEmDashEntry, getEntryTerms, getSeoMeta } from "emdash";
import { Image, PortableText, WidgetArea } from "emdash/ui";
import Base from "../../layouts/Base.astro";
const { slug } = Astro.params;
if (!slug) {
return Astro.redirect("/404");
}
const { entry: post, cacheHint } = await getEmDashEntry("posts", slug);
if (!post) {
return Astro.redirect("/404");
}
Astro.cache.set(cacheHint);
// SEO meta from content fields
const seo = getSeoMeta(post, {
siteTitle: "My Site",
siteUrl: Astro.url.origin,
path: `/posts/${slug}`,
});
// Taxonomy terms for this post (use post.data.id, not post.id)
const tags = await getEntryTerms("posts", post.data.id, "tag");
const categories = await getEntryTerms("posts", post.data.id, "category");
---
<Base
title={seo.title}
description={seo.description}
canonical={seo.canonical}
image={seo.ogImage}
content={{ collection: "posts", id: post.data.id, slug }}
>
<article>
{
post.data.featured_image && (
<div {...post.edit.featured_image}>
<Image image={post.data.featured_image} />
</div>
)
}
<h1 {...post.edit.title}>{post.data.title}</h1>
{
post.data.publishedAt && (
<time datetime={post.data.publishedAt.toISOString()}>
{post.data.publishedAt.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})}
</time>
)
}
{
categories.length > 0 && (
<div>
{categories.map((c) => (
<a href={`/category/${c.slug}`}>{c.label}</a>
))}
</div>
)
}
<div {...post.edit.content}>
<PortableText value={post.data.content} />
</div>
{
tags.length > 0 && (
<div>
{tags.map((t) => (
<a href={`/tag/${t.slug}`}>{t.label}</a>
))}
</div>
)
}
</article>
<aside>
<WidgetArea name="sidebar" />
</aside>
</Base>

View File

@@ -0,0 +1,49 @@
---
import { getEmDashCollection, getEntryTerms } from "emdash";
import { Image } from "emdash/ui";
import Base from "../../layouts/Base.astro";
const { entries: posts, cacheHint } = await getEmDashCollection("posts", {
orderBy: { published_at: "desc" },
});
Astro.cache.set(cacheHint);
// Fetch tags for each post
const postsWithTags = await Promise.all(
posts.map(async (post) => {
const tags = await getEntryTerms("posts", post.data.id, "tag");
return { post, tags };
})
);
---
<Base title="All Posts">
<h1>Posts</h1>
{
postsWithTags.length === 0 ? (
<p>No posts yet.</p>
) : (
<ul>
{postsWithTags.map(({ post, tags }) => (
<li>
<a href={`/posts/${post.id}`}>
{post.data.featured_image && (
<Image image={post.data.featured_image} />
)}
<h2>{post.data.title}</h2>
</a>
{post.data.excerpt && <p>{post.data.excerpt}</p>}
{tags.length > 0 && (
<div>
{tags.map((t) => (
<a href={`/tag/${t.slug}`}>{t.label}</a>
))}
</div>
)}
</li>
))}
</ul>
)
}
</Base>