logicsrc/apps/logicsrc-web/src/app/sitemap.ts
Anthony Ettinger 30facd71ff
Add OpenMCP: an open catalog of MCP relays (#153)
A relay serves /.well-known/openmcp.json; a catalog probes it (the
descriptor from the relay's own origin, then initialize and tools/list)
and lists only what it found; a client reaches every relay through the
catalog's REST, its own MCP endpoint, or signed webhooks. Landing page at
/openmcp, the document at /docs/openmcp, registered in the same four
places as the other specs. Reference implementation at
github.com/logicsrc/openmcp.


Claude-Session: https://claude.ai/code/session_01FMT2v1YxmgcDuionrfT719

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-12 09:55:14 -07:00

84 lines
3.4 KiB
TypeScript

import type { MetadataRoute } from "next";
import { publicClient } from "@/lib/supabase";
import { DOC_SLUGS } from "@/lib/docs";
import { REPORTED_SPECS, reportIds } from "@/lib/reports";
export const dynamic = "force-dynamic";
function baseUrl(): string {
return (process.env.PUBLIC_URL ?? "https://logicsrc.com").replace(/\/$/, "");
}
// Static routes preserved from the legacy public/sitemap.xml.
const STATIC_ROUTES: Array<{
path: string;
changeFrequency: MetadataRoute.Sitemap[number]["changeFrequency"];
priority: number;
}> = [
{ path: "/", changeFrequency: "weekly", priority: 1.0 },
{ path: "/docs", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openontology", changeFrequency: "weekly", priority: 0.9 },
{ path: "/opencreds", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openswarm", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openprd", changeFrequency: "weekly", priority: 0.9 },
{ path: "/asdlc", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openprofile", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openmcp", changeFrequency: "weekly", priority: 0.9 },
{ path: "/openontology/explore", changeFrequency: "daily", priority: 0.7 },
{ path: "/openspec", changeFrequency: "weekly", priority: 0.8 },
{ path: "/agent-swarm", changeFrequency: "weekly", priority: 0.8 },
{ path: "/agentbyte", changeFrequency: "weekly", priority: 0.8 },
{ path: "/credential-sharing", changeFrequency: "weekly", priority: 0.8 },
{ path: "/hire-us", changeFrequency: "weekly", priority: 0.8 },
{ path: "/pricing", changeFrequency: "monthly", priority: 0.7 },
{ path: "/blog", changeFrequency: "daily", priority: 0.7 },
{ path: "/about", changeFrequency: "monthly", priority: 0.6 },
{ path: "/terms", changeFrequency: "monthly", priority: 0.4 },
{ path: "/privacy", changeFrequency: "monthly", priority: 0.4 },
];
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const base = baseUrl();
const staticEntries: MetadataRoute.Sitemap = STATIC_ROUTES.map((route) => ({
url: `${base}${route.path}`,
changeFrequency: route.changeFrequency,
priority: route.priority,
}));
const docEntries: MetadataRoute.Sitemap = DOC_SLUGS.map((slug) => ({
url: `${base}/docs/${slug}`,
changeFrequency: "monthly",
priority: 0.6,
}));
// Benchmark reports: the index per reported spec, and each published report.
const reportEntries: MetadataRoute.Sitemap = [];
for (const slug of REPORTED_SPECS) {
reportEntries.push({ url: `${base}/docs/${slug}/reports`, changeFrequency: "monthly", priority: 0.5 });
for (const id of reportIds(slug)) {
reportEntries.push({ url: `${base}/docs/${slug}/reports/${id}`, changeFrequency: "yearly", priority: 0.4 });
}
}
let postEntries: MetadataRoute.Sitemap = [];
try {
const supabase = publicClient();
const { data } = await supabase
.from("blog_posts")
.select("slug, published_at, updated_at")
.eq("status", "published")
.order("published_at", { ascending: false });
postEntries = (data ?? []).map((post) => ({
url: `${base}/blog/${post.slug}`,
lastModified: new Date(post.updated_at ?? post.published_at),
changeFrequency: "weekly",
priority: 0.6,
}));
} catch {
// If the DB is unreachable, still serve the static sitemap.
postEntries = [];
}
return [...staticEntries, ...docEntries, ...reportEntries, ...postEntries];
}