CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
seo.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 5618f9a | 1 | /** |
| 2 | * SEO routes: robots.txt + sitemap.xml. | |
| 3 | * | |
| 4 | * robots.txt — allow crawlers on public surfaces, disallow admin/settings | |
| 5 | * and API write paths. | |
| 6 | * sitemap.xml — lists the stable public URLs (landing, explore, status, | |
| 7 | * marketplace, graphql explorer, shortcuts, terms). Public repo URLs are | |
| 8 | * not enumerated here — those live behind /explore which crawlers follow. | |
| 9 | */ | |
| 10 | ||
| 11 | import { Hono } from "hono"; | |
| 12 | ||
| 13 | const seo = new Hono(); | |
| 14 | ||
| 15 | const ROBOTS = `User-agent: * | |
| 16 | Allow: / | |
| 17 | Disallow: /admin | |
| 18 | Disallow: /settings | |
| 19 | Disallow: /api/ | |
| 20 | Disallow: /login | |
| 21 | Disallow: /register | |
| 22 | Disallow: /logout | |
| 23 | Disallow: /oauth/ | |
| 24 | Disallow: /*/settings | |
| 25 | Disallow: /*.git/ | |
| 26 | ||
| 27 | Sitemap: /sitemap.xml | |
| 28 | `; | |
| 29 | ||
| 30 | seo.get("/robots.txt", (c) => { | |
| 31 | c.header("Content-Type", "text/plain; charset=utf-8"); | |
| 32 | c.header("Cache-Control", "public, max-age=3600"); | |
| 33 | return c.body(ROBOTS); | |
| 34 | }); | |
| 35 | ||
| 36 | const STATIC_PATHS = [ | |
| 37 | "/", | |
| 38 | "/explore", | |
| 39 | "/marketplace", | |
| 40 | "/status", | |
| 80bed05 | 41 | "/help", |
| 5618f9a | 42 | "/shortcuts", |
| 43 | "/api/graphql", | |
| 44 | "/terms", | |
| 45 | "/privacy", | |
| 46 | "/acceptable-use", | |
| 47 | ]; | |
| 48 | ||
| 49 | seo.get("/sitemap.xml", (c) => { | |
| 50 | const origin = new URL(c.req.url).origin; | |
| 51 | const lastmod = new Date().toISOString().slice(0, 10); | |
| 52 | const urls = STATIC_PATHS.map( | |
| 53 | (p) => | |
| 54 | `<url><loc>${origin}${p}</loc><lastmod>${lastmod}</lastmod></url>` | |
| 55 | ).join("\n "); | |
| 56 | const body = `<?xml version="1.0" encoding="UTF-8"?> | |
| 57 | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | |
| 58 | ${urls} | |
| 59 | </urlset> | |
| 60 | `; | |
| 61 | c.header("Content-Type", "application/xml; charset=utf-8"); | |
| 62 | c.header("Cache-Control", "public, max-age=3600"); | |
| 63 | return c.body(body); | |
| 64 | }); | |
| 65 | ||
| 66 | export default seo; |