mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Replaces the Next.js/Prisma/next-auth app with a single-container Hono server, SQLite via Drizzle, OIDC login against Authentik and a React/Vite admin UI that talks to a JSON API. - users get /<username>/<code>, admins (Authentik group) get root codes, pinning and full access - link pages with link and Markdown text blocks, themes, avatars - editable 302 redirects, random or custom codes - personal API tokens, CSRF-protected cookie sessions - privacy-friendly stats: daily-rotating visitor salt, 90-day click retention with daily totals kept - QR codes as PNG/SVG - tests for permissions, auth, redirects and stats; CI runs them before publishing images See REQUIREMENTS.md for the full requirement list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
17 lines
650 B
TypeScript
17 lines
650 B
TypeScript
import MarkdownIt from "markdown-it";
|
|
|
|
// Raw HTML and images are disabled; markdown-it also rejects javascript: and similar link targets.
|
|
const md = new MarkdownIt({ html: false, linkify: true, breaks: true }).disable(["image", "table"]);
|
|
|
|
const defaultLinkOpen =
|
|
md.renderer.rules.link_open ?? ((tokens, idx, options, _env, self) => self.renderToken(tokens, idx, options));
|
|
|
|
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
|
|
tokens[idx]?.attrSet("rel", "noopener nofollow");
|
|
return defaultLinkOpen(tokens, idx, options, env, self);
|
|
};
|
|
|
|
export function renderMarkdown(source: string): string {
|
|
return md.render(source);
|
|
}
|