mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-10-02 20:57:03 +00:00
feat(web): blog-post ingestion webhook + /blog, dynamic RSS & sitemap
Add an autoblog webhook receiver and a Supabase-backed blog to logicsrc-web (the app had no Supabase usage before). - Migration: blog_posts table (RLS: public reads published, service-role writes). Applied to the linked project. - POST /api/webhooks/blog: verifies the Standard Webhooks signature against BLOG_WEBHOOK_SECRET via @profullstack/autoblog verifyAndParse (no admin user — shared secret only) and upserts the post by slug. - /blog index + /blog/[slug] render published posts from the table. - /blog/rss.xml and /sitemap.xml are now dynamic, generated from the table; removed the static public/sitemap.xml and public/blog/rss.xml. - BLOG_WEBHOOK_SECRET added to .env.example. Verified end-to-end: a signed sample post delivered 200 and appeared in the index, post page, RSS, and sitemap; build + typecheck pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
ade606c157
commit
cf99e93c53
13 changed files with 549 additions and 82 deletions
58
apps/logicsrc-web/src/app/sitemap.ts
Normal file
58
apps/logicsrc-web/src/app/sitemap.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import type { MetadataRoute } from "next";
|
||||
import { publicClient } from "@/lib/supabase";
|
||||
|
||||
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: "/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: "/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,
|
||||
}));
|
||||
|
||||
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, ...postEntries];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue