Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions blog-cloudflare/src/layouts/Base.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { getMenu, getEmDashCollection } from "emdash";
import { getMenu, getEmDashCollection, getSiteSettings } from "emdash";
import {
WidgetArea,
EmDashHead,
Expand All @@ -11,7 +11,7 @@ import LiveSearch from "emdash/ui/search";
import "../styles/theme.css";

interface Props {
title: string;
title?: string;
description?: string | null;
image?: string | null;
canonical?: string | null;
Expand All @@ -36,9 +36,16 @@ const {
author,
content,
} = Astro.props;
const siteTitle = "My Blog";
// If title already includes site title (from getSeoMeta), use as-is
const fullTitle = title.includes(siteTitle) ? title : `${title} — ${siteTitle}`;
// Read site title + tagline from EmDash settings (admin-editable)
const settings = await getSiteSettings();
const siteTitle = settings?.title ?? "EmDash";
const siteTagline = settings?.tagline ?? "";

const fullTitle = !title
? siteTitle
: title.includes(siteTitle)
? title
: `${title} — ${siteTitle}`;

// Fetch primary menu defined in seed
const menu = await getMenu("primary");
Expand Down Expand Up @@ -136,7 +143,7 @@ const isLoggedIn = !!Astro.locals.user;
<div class="footer-grid">
<div class="footer-brand">
<a href="/" class="footer-logo">{siteTitle}</a>
<p class="footer-tagline">Thoughts, stories, and ideas.</p>
{siteTagline && <p class="footer-tagline">{siteTagline}</p>}
</div>
<div class="footer-nav">
<h4 class="footer-heading">Navigate</h4>
Expand Down
2 changes: 1 addition & 1 deletion blog-cloudflare/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function formatDate(date: Date | null | undefined) {
}
---

<Base title="My Blog" description="Welcome to my blog">
<Base>
{
posts.length === 0 ? (
<section class="empty-state">
Expand Down
4 changes: 3 additions & 1 deletion blog-cloudflare/src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getEmDashCollection,
getEntryTerms,
getSeoMeta,
getSiteSettings,
} from "emdash";
import {
Image,
Expand Down Expand Up @@ -54,8 +55,9 @@ function getImageUrl(img: unknown): string | undefined {
const featuredImageUrl = getImageUrl(post.data.featured_image);

// Generate SEO meta from content
const siteSettings = await getSiteSettings();
const seo = getSeoMeta(post, {
siteTitle: "My Blog",
siteTitle: siteSettings?.title ?? "EmDash",
siteUrl: Astro.url.origin,
path: `/posts/${slug}`,
defaultOgImage: featuredImageUrl,
Expand Down
9 changes: 5 additions & 4 deletions blog-cloudflare/src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { APIRoute } from "astro";
import { getEmDashCollection } from "emdash";

const siteTitle = "My Blog";
const siteDescription = "A blog about software, design, and the occasional stray thought.";
import { getEmDashCollection, getSiteSettings } from "emdash";

export const GET: APIRoute = async ({ site, url }) => {
const siteUrl = site?.toString() || url.origin;

const settings = await getSiteSettings();
const siteTitle = settings?.title ?? "EmDash";
const siteDescription = settings?.tagline ?? "";

const { entries: posts } = await getEmDashCollection("posts", {
orderBy: { published_at: "desc" },
limit: 20,
Expand Down