The embeddable /badge/<user>.svg route (deployed 2026-11-27) rendered a confident-looking badge for any handle, real or not. It now looks the user up via the existing explicit-select GET /v1/users/:id route and renders a neutral "not found" SVG (HTTP 404) for unknown handles, while showing a live post count for real ones. The lookup fails open (no 404) on a slow/unreachable backend so this stays a reliable public image endpoint rather than a hard API dependency. Also adds the two missing pieces from the Hashnode-style backlink wedge: a "copy badge" icon button on a user's own profile (copies the markdown snippet) and a /docs/badge page explaining the URL, markdown/HTML snippets, and the privacy posture (username + public post count only, same fields already on any public profile). Verified locally end-to-end: started the real backend (local Postgres) + web dev server — an existing seeded user returns 200 with a live post count, an unknown handle returns the 404 SVG, invalid characters still 400, and killing the backend falls back to the neutral badge instead of a false 404. `tsc --noEmit` clean across the whole web app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import type { MetadataRoute } from 'next'
|
|
import { RITGRAM_SITE_URL as SITE_URL } from '@/lib/site-config'
|
|
|
|
// Static, always-public marketing/discovery routes. User/repo profile pages
|
|
// are dynamic ([username], [owner]/[repo]) and intentionally left out here
|
|
// rather than querying the database at build time from this file; add a
|
|
// dedicated sitemap route (e.g. app/sitemap/[id]/route.ts with
|
|
// generateSitemaps) if those need to be indexed individually.
|
|
const STATIC_ROUTES = [
|
|
'',
|
|
'/explore',
|
|
'/discover',
|
|
'/trending',
|
|
'/search',
|
|
'/pricing',
|
|
'/about',
|
|
'/terms',
|
|
'/privacy-policy',
|
|
'/docs/import-from-github',
|
|
'/docs/rithub-vs-github',
|
|
'/docs/rithub-vs-gitlab',
|
|
'/docs/rithub-vs-codeberg',
|
|
'/docs/github-account-suspended',
|
|
'/docs/rit',
|
|
'/docs/badge',
|
|
]
|
|
|
|
export default function sitemap(): MetadataRoute.Sitemap {
|
|
const now = new Date()
|
|
return STATIC_ROUTES.map((path) => ({
|
|
url: `${SITE_URL}${path}`,
|
|
lastModified: now,
|
|
changeFrequency: path === '' ? 'daily' : 'weekly',
|
|
priority: path === '' ? 1 : 0.7,
|
|
}))
|
|
}
|