app: announcements, devotionals and events' screens; @crosscode/seo 1.1.0 (APP-1.0-PLAN §5-§7)

Public pages: Home with today's devotional, the latest announcements (pinned
first) and what's on; Announcements and each one's page (markdown without
HTML, a button, Article JSON-LD; members-only ones ask for a sign-in and are
noindex); Devotional (the passage in full with its copyright line, Read in
YouVersion, the prayer), each day's page, the archive by month and the
Acknowledgements; Events and each one's page (Register on the Events site for
Cross Events', a canonical to the origin, Event JSON-LD on the App's own).
A sitemap of the public pages, named in robots.txt.

Admin: Announcements (schedule, end, pin, campus, who sees it, also send it),
Events (simple events, Linked products: publish and show events from), and
Devotionals (Cross Code's or our own, Sync now, a month's days, writing, the
CSV import with its preview, keep or replace days already filled).

@crosscode/seo 1.1.0: articleJsonLd. The backend gives the App's own address
and the sitemap's list, and a simple event's crosscode.event/1 for its page.

Checked in a browser on a throwaway PostgreSQL: the pages for a visitor, the
JSON-LD, a members-only announcement asking for a sign-in, the sitemap, a
Content admin publishing an announcement and a Devotional writer saving one;
no page errors. 94 backend tests, 19 seo tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 11:36:41 +02:00
co-authored by Claude Opus 5.5
parent a9079f1195
commit 0ac6827ddd
43 changed files with 1482 additions and 30 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@crosscode/seo",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"description": "schema.org JSON-LD and meta helpers every public Cross Code site uses, built on @crosscode/contracts (ROADMAP-v3 §11)",
"license": "UNLICENSED",
+51
View File
@@ -0,0 +1,51 @@
/**
* schema.org `Article` JSON-LD for a page of writing: the Church App's devotionals and public
* announcements (APP-1.0-PLAN §5, §6, §11). The same shape for every product, so search engines
* see the title, date, author and the church that published it.
*
* Members-only pages are noindex and never get this.
*/
type JsonLd = Record<string, unknown>;
export interface ArticleJsonLdInput {
/** The page's canonical address. */
url: string;
headline: string;
/** A short summary (the meta description). */
description?: string | null;
/** ISO date or date-time it was published. */
datePublished: string;
dateModified?: string | null;
/** A person's name; the church is used when there's none. */
author?: string | null;
imageUrl?: string | null;
/** The church publishing it. */
publisher: { name: string; url?: string | null; logoUrl?: string | null };
/** For a devotional: the passage it's about, e.g. "John 15:1-5". */
about?: string | null;
}
/** Google's headline limit for articles. */
export const HEADLINE_MAX = 110;
export function articleJsonLd(a: ArticleJsonLdInput): JsonLd {
const publisher: JsonLd = { "@type": "Organization", name: a.publisher.name };
if (a.publisher.url) publisher.url = a.publisher.url;
if (a.publisher.logoUrl) publisher.logo = { "@type": "ImageObject", url: a.publisher.logoUrl };
const out: JsonLd = {
"@context": "https://schema.org",
"@type": "Article",
mainEntityOfPage: { "@type": "WebPage", "@id": a.url },
url: a.url,
headline: a.headline.length > HEADLINE_MAX ? `${a.headline.slice(0, HEADLINE_MAX - 1).trimEnd()}…` : a.headline,
datePublished: a.datePublished,
dateModified: a.dateModified ?? a.datePublished,
author: a.author ? { "@type": "Person", name: a.author } : publisher,
publisher,
};
if (a.description) out.description = a.description;
if (a.imageUrl) out.image = [a.imageUrl];
if (a.about) out.about = { "@type": "CreativeWork", name: a.about };
return out;
}
+1
View File
@@ -6,3 +6,4 @@
export * from "./event";
export * from "./church";
export * from "./meta";
export * from "./article";
+21 -1
View File
@@ -1,7 +1,7 @@
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { churchSchema, eventSchema, type Church, type CrosscodeEvent } from "@crosscode/contracts";
import { canonicalUrl, churchJsonLd, eventJsonLd, jsonLdString, pageMeta, truncate } from "../src";
import { articleJsonLd, canonicalUrl, churchJsonLd, eventJsonLd, jsonLdString, pageMeta, truncate } from "../src";
const SAMPLES = join(__dirname, "..", "..", "contracts", "samples");
const sample = <T>(file: string): T => JSON.parse(readFileSync(join(SAMPLES, file), "utf8")) as T;
@@ -139,3 +139,23 @@ describe("meta", () => {
expect(jsonLdString({ name: "</script><script>alert(1)</script>" })).not.toContain("</script>");
});
});
describe("articleJsonLd", () => {
const base = { url: "https://app.acaciahill.test/devotional/2026-12-01", headline: "Abide", datePublished: "2026-12-01", publisher: { name: "Acacia Hill", url: "https://acaciahill.test", logoUrl: "https://acaciahill.test/logo.svg" } };
it("names the article, its page, its author and the church", () => {
const ld = articleJsonLd({ ...base, author: "Pastor Sam", about: "John 15:1-5", description: "Abide in me." });
expect(ld).toMatchObject({
"@type": "Article", headline: "Abide", url: base.url, mainEntityOfPage: { "@id": base.url }, datePublished: "2026-12-01", dateModified: "2026-12-01",
author: { "@type": "Person", name: "Pastor Sam" }, publisher: { name: "Acacia Hill", logo: { url: "https://acaciahill.test/logo.svg" } },
about: { name: "John 15:1-5" }, description: "Abide in me.",
});
});
it("credits the church when there's no author, and cuts a long headline", () => {
const ld = articleJsonLd({ ...base, headline: "x".repeat(200) });
expect(ld.author).toEqual(ld.publisher);
expect((ld.headline as string).length).toBe(110);
expect(jsonLdString(ld)).not.toContain("</script");
});
});