diff --git a/nostr/commit-signatures.jsonl b/nostr/commit-signatures.jsonl index ff264c7..3a1f879 100644 --- a/nostr/commit-signatures.jsonl +++ b/nostr/commit-signatures.jsonl @@ -84,3 +84,4 @@ {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772004731,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","increase granularity of repo and event visbility"]],"content":"Signed commit: increase granularity of repo and event visbility","id":"1d96ac54006360066d403209f6893faffec0f8f389ea99af73447a017d5ff03a","sig":"44c53034e91ef444368a5034e3a12024bf893f3e518eef903aecbbb453e612f5f198601daf7b9d8da3bc48ca77ec4d18795f111211c3bc32ed4b6c0707a7a905"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772005973,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","update the API"]],"content":"Signed commit: update the API","id":"09329cf7eb8c228e87e365b0d7a4d052ddb08b3cf7f75162b2e9b8dd77e917a0","sig":"1a1b40b18dbd744bd4043f0f18d5945ba7d1f738d36bb8457c4ec806832cd1b44ed36417c24d01511fa7fddfa33c376bf24c2fdf478bf1ab015cf4c524aac7e8"} {"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772008194,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","revamp tutoral and ReadMe documentation\nupdate API docs"]],"content":"Signed commit: revamp tutoral and ReadMe documentation\nupdate API docs","id":"9d1fb9db75e26a5fcdcab54253ef1c6126ea1e01e98728554435e655354f6238","sig":"0cfde0ac8a7083479c982c7f212a91eee7e8ed33b43b30291677fe3a126638ae4fde03893aa5d492f8f6fc8e066b7c46bd6f07246376a5d9e56becc73e4e48d8"} +{"kind":1640,"pubkey":"573634b648634cbad10f2451776089ea21090d9407f715e83c577b4611ae6edc","created_at":1772008707,"tags":[["author","Silberengel","silberengel7@protonmail.com"],["message","fix bugs\nsign sync commits"]],"content":"Signed commit: fix bugs\nsign sync commits","id":"3b05eb0074772bd7d3322e0a32ef8932dbafa2334ff51a75ed5159fcdfdb3558","sig":"b7bdc3272a6daddf409dc519de6e06a4ee85407a14790996be7c5039a00358106285a8fc00084d9016587df529d7026f28108384976198789aa1fd60140a5738"} diff --git a/src/routes/[...path]/+server.ts b/src/routes/[...path]/+server.ts new file mode 100644 index 0000000..1b15f6f --- /dev/null +++ b/src/routes/[...path]/+server.ts @@ -0,0 +1,29 @@ +/** + * Catch-all route to handle .md files at root level + * Redirects /nostr-integration.md -> /docs/nostr-integration + * + * Note: This route only handles .md files. Other routes take precedence. + */ + +import { redirect, error } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ params }) => { + const path = params.path; + + // Only handle .md files - return 404 for everything else + if (!path || !path.endsWith('.md')) { + throw error(404, 'Not found'); + } + + // Extract filename without .md extension + const filename = path.replace(/\.md$/, ''); + + // Security: Only allow alphanumeric, hyphens, underscores + if (!/^[a-zA-Z0-9_-]+$/.test(filename)) { + throw error(400, 'Invalid documentation path'); + } + + // Redirect to docs route + throw redirect(302, `/docs/${filename}`); +}; diff --git a/src/routes/docs/[slug]/+page.server.ts b/src/routes/docs/[slug]/+page.server.ts index 632c1db..a003337 100644 --- a/src/routes/docs/[slug]/+page.server.ts +++ b/src/routes/docs/[slug]/+page.server.ts @@ -15,6 +15,11 @@ import logger from '$lib/services/logger.js'; export const load: PageServerLoad = async ({ params }: { params: { slug: string } }) => { let slug = params.slug; + // Strip .md extension if present (handles /docs/nostr-integration.md -> nostr-integration) + if (slug.endsWith('.md')) { + slug = slug.slice(0, -3); + } + // Security: Only allow alphanumeric, hyphens, underscores, and dots if (!/^[a-zA-Z0-9._-]+$/.test(slug)) { throw error(400, 'Invalid documentation path');