Files
probably-rendering-one-more…/apps/waterfall-wiki/src/pages/api/wiki-post/[slug].ts
T
codex-bot ad398db781
waterfall-wiki CI and deployment / verify-and-deploy (push) Has been cancelled
studio CI and deployment / verify-and-deploy (push) Successful in 9m15s
Restore PROMPT branding, rename waterfall-wiki, and add system tag workflows
2026-10-27 00:35:59 +08:00

4 lines
750 B
TypeScript

import type {NextApiRequest,NextApiResponse} from 'next';
import {getPost} from '@/lib/library';
export default async function handler(req:NextApiRequest,res:NextApiResponse){if(req.method!=='GET'&&req.method!=='HEAD')return res.status(405).end();try{const post=await getPost(String(req.query.slug||''));if(!post)return res.status(404).end();res.setHeader('Content-Type','text/markdown; charset=utf-8');res.send('# '+post.title+'\n\nNamespace: '+(['image','video','audio'].includes(post.kind)?'File':'Main')+'\n\n'+post.assets.map(a=>a.kind==='text'?a.body:`- ${a.kind}: [${a.filename||a.id}](/api/media/${a.id})`).join('\n\n')+'\n\nCategories: '+post.tags.map(t=>t.name).join(', '));}catch{res.status(503).send('Storage temporarily unavailable');}}