CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
legal.tsx
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 36b4cbd | 1 | /** |
| 2 | * Legal pages — Terms, Privacy, AUP served from the website. | |
| 3 | */ | |
| 4 | ||
| 5 | import { Hono } from "hono"; | |
| 6 | import { readFileSync } from "fs"; | |
| 7 | import { join } from "path"; | |
| 8 | import { Layout } from "../views/layout"; | |
| 9 | import { renderMarkdown, markdownCss } from "../lib/markdown"; | |
| 10 | import { softAuth } from "../middleware/auth"; | |
| 11 | import type { AuthEnv } from "../middleware/auth"; | |
| 12 | import { html } from "hono/html"; | |
| 13 | ||
| 14 | const legal = new Hono<AuthEnv>(); | |
| 15 | ||
| 16 | legal.use("*", softAuth); | |
| 17 | ||
| 18 | function serveLegalPage(title: string, filename: string) { | |
| 19 | return async (c: any) => { | |
| 20 | const user = c.get("user"); | |
| 21 | let content: string; | |
| 22 | try { | |
| 23 | content = readFileSync( | |
| 24 | join(process.cwd(), "legal", filename), | |
| 25 | "utf-8" | |
| 26 | ); | |
| 27 | } catch { | |
| 28 | content = `# ${title}\n\nThis page is being prepared. Check back soon.`; | |
| 29 | } | |
| 30 | ||
| 31 | const rendered = renderMarkdown(content); | |
| 32 | ||
| 33 | return c.html( | |
| 34 | <Layout title={title} user={user}> | |
| 35 | <style>{markdownCss}</style> | |
| 36 | <div class="markdown-body" style="max-width: 800px; margin: 0 auto"> | |
| 37 | {html([rendered] as unknown as TemplateStringsArray)} | |
| 38 | </div> | |
| 39 | </Layout> | |
| 40 | ); | |
| 41 | }; | |
| 42 | } | |
| 43 | ||
| 44 | legal.get("/terms", serveLegalPage("Terms of Service", "TERMS.md")); | |
| 45 | legal.get("/privacy", serveLegalPage("Privacy Policy", "PRIVACY.md")); | |
| 46 | legal.get("/acceptable-use", serveLegalPage("Acceptable Use Policy", "AUP.md")); | |
| 47 | ||
| 48 | export default legal; |