mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 17:24:48 +00:00
seo: give every page its own social title, not the homepage's (#203)
Reddit, Slack, X and Facebook read og:title, and every page of
logicsrc.com was serving the homepage's. The <title> tag was correct per
page, which is why it went unnoticed: Next.js shallow-merges metadata, so
a page exporting only `{ title, description, alternates }` inherits the
root layout's `openGraph` object whole. og:title, og:description and
og:url were the homepage's on all 45 spec landing pages, every doc, every
report and every SPA section.
Blog posts were the one route that declared openGraph, and they proved
the mechanism: their og:title is right. They also showed the other half
of it -- declaring openGraph drops the file-convention opengraph-image,
so live posts shipped with no og:image at all, and their twitter:title
was still the homepage's.
- src/lib/page-meta.ts: one builder, three entry points. specMetadata
titles a spec landing page from its lib/specs.ts entry, pageMetadata
titles the site's own pages from PAGE_META, contentMetadata titles a
doc, post, skill or ontology record from its content. All three always
emit openGraph and twitter title, description, url and image.
- Spec titles come from the registry, so they cannot drift from the way
the sidebar, /specs and the home page describe the same spec, and a new
spec page is titled the moment its registry entry exists. composeTitle
trims a long subject line at a clause boundary to fit a link preview.
- Doc pages carry that subject line too, because every spec's H1 is just
its name: "OpenStream" alone was the whole title.
- docExcerpt joins the wrapped lines of the first real paragraph and
skips Status:/Slug: headers and list lead-ins, so descriptions stopped
being "Status: 0.1 draft" and "Core tables:".
- contract/page-metadata.contract.test.ts fails if a sitemap route has no
title, if a spec page has no registry entry, if two pages share a
title, if a page declares metadata without the builder, or if a page
loses its social image.
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
baa3adf716
commit
61870aa481
57 changed files with 909 additions and 361 deletions
|
|
@ -2,6 +2,7 @@ import Link from "next/link";
|
|||
import { notFound } from "next/navigation";
|
||||
import type { ReactNode } from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { contentMetadata, notFoundMetadata } from "@/lib/page-meta";
|
||||
import { publicClient } from "@/lib/supabase";
|
||||
import { SiteShell } from "@/components/site-shell";
|
||||
import { AdUnit } from "@/components/ad-unit";
|
||||
|
|
@ -57,20 +58,21 @@ export async function generateMetadata({
|
|||
}): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
const post = await loadPost(slug);
|
||||
if (!post) return { title: "Not found · LogicSRC" };
|
||||
return {
|
||||
title: `${post.title} · LogicSRC`,
|
||||
description: post.excerpt ?? undefined,
|
||||
if (!post) return notFoundMetadata("post");
|
||||
// This route already set openGraph, which is why its og:title was right --
|
||||
// and why it had no og:image: declaring openGraph suppresses the
|
||||
// file-convention card, and `images: undefined` did not bring it back.
|
||||
// contentMetadata names the card explicitly.
|
||||
return contentMetadata({
|
||||
title: post.title,
|
||||
description: post.excerpt ?? `${post.title} — from the LogicSRC blog.`,
|
||||
path: `/blog/${post.slug}`,
|
||||
// A guest post points its canonical at the original; an original post is
|
||||
// canonical to itself.
|
||||
alternates: { canonical: post.canonical_url ?? `/blog/${post.slug}` },
|
||||
openGraph: {
|
||||
title: post.title,
|
||||
description: post.excerpt ?? undefined,
|
||||
type: "article",
|
||||
images: post.featured_image?.url ? [post.featured_image.url] : undefined,
|
||||
},
|
||||
};
|
||||
canonical: post.canonical_url ?? `/blog/${post.slug}`,
|
||||
type: "article",
|
||||
...(post.featured_image?.url ? { images: [post.featured_image.url] } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
function formatDate(value: string): string {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
import Link from "next/link";
|
||||
import type { ReactNode } from "react";
|
||||
import type { Metadata } from "next";
|
||||
import { pageMetadata } from "@/lib/page-meta";
|
||||
import { publicClient } from "@/lib/supabase";
|
||||
import { SiteShell } from "@/components/site-shell";
|
||||
import { AdUnit } from "@/components/ad-unit";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Blog · LogicSRC",
|
||||
description:
|
||||
"Project notes for LogicSRC OpenSpec standards, AgentSwarm, AgentByte, SDKs, MCP, and reference implementations.",
|
||||
alternates: { types: { "application/rss+xml": "/blog/rss.xml" } },
|
||||
};
|
||||
export const metadata: Metadata = pageMetadata("/blog", {
|
||||
alternateTypes: { "application/rss+xml": "/blog/rss.xml" },
|
||||
});
|
||||
|
||||
type PostRow = {
|
||||
slug: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue