videogen/apps/web/app/sitemap.ts
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

71 lines
2.9 KiB
TypeScript

import type { MetadataRoute } from "next";
import { SITE_URL, buildSitemapEntries } from "@/lib/seo";
import { getLeaderboard } from "@/lib/api";
import { loadReelGalleryFeed, reelGalleryItemPath } from "@/lib/seo/reel-gallery/feed";
/**
* Sitemap (Next.js App Router). Enumerates every public, indexable marketing
* route: the landing page, pricing, the editor, the tools/features/guides hub
* pages, and every programmatically generated page. The URL list is derived
* from the SEO data module (`@/lib/seo`), so adding a use case or guide extends the
* sitemap automatically. Authenticated app surfaces are intentionally excluded.
*/
// Computed once at module load (one per deployment), not per request — a
// `lastmod` that changes on every crawl is indistinguishable from no
// `lastmod` at all, so Google ignores it (SEO audit, 2026-10-19). This still
// isn't a true per-page content date, but it now only moves when the site
// actually redeploys, which is the signal lastmod is supposed to carry.
const DEPLOY_TIME = new Date();
/** Top public creator profiles with at least one published template — the
* same "thin profile" bar `creators/[handle]/page.tsx`'s `generateMetadata`
* uses to decide `noindex`. `GET /creators/leaderboard` is public and
* capped at 100 results, so this is one bounded request, not an unbounded
* crawl of every creator. Any API failure (cold build, offline CI) degrades
* to no creator entries rather than failing the whole sitemap.
*/
async function creatorSitemapEntries(lastModified: Date): Promise<MetadataRoute.Sitemap> {
try {
const rows = await getLeaderboard({ limit: 100 });
const seen = new Set<string>();
const entries: MetadataRoute.Sitemap = [];
for (const row of rows) {
const handle = row.handle?.trim();
if (!handle || row.published_template_count <= 0 || seen.has(handle.toLowerCase())) continue;
seen.add(handle.toLowerCase());
entries.push({
url: `${SITE_URL}/creators/${encodeURIComponent(handle)}`,
lastModified,
changeFrequency: "weekly",
priority: 0.5,
});
}
return entries;
} catch {
return [];
}
}
/** `/reel-gallery/<id>` detail pages — one per real published demo reel. The
* manifest fetch already degrades to an empty list on any failure (see
* `loadReelGalleryFeed`), so a slow or offline media host never breaks the
* rest of the sitemap.
*/
async function reelGallerySitemapEntries(lastModified: Date): Promise<MetadataRoute.Sitemap> {
const items = await loadReelGalleryFeed();
return items.map((item) => ({
url: `${SITE_URL}${reelGalleryItemPath(item)}`,
lastModified,
changeFrequency: "weekly",
priority: 0.5,
}));
}
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const [creators, reels] = await Promise.all([
creatorSitemapEntries(DEPLOY_TIME),
reelGallerySitemapEntries(DEPLOY_TIME),
]);
return [...buildSitemapEntries(DEPLOY_TIME), ...creators, ...reels];
}