Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
TypeScript
at feat/nuxt-v5
12345678910111213141516171819202122232425262728293031323334353637383940414243import { defineEventHandler } from 'nuxt/server'
import { pageMeta } from '#md-page-meta'
import { getUses } from '../utils/cms/uses'
export default defineEventHandler(async event => { if (import.meta.test) { return mdResponse(event, '') }
const categories = await getUses() const sorted = [...categories].sort((a, b) => (a.order || 100) - (b.order || 100))
const lines = [ mdFrontmatter('/uses', pageMeta['/uses']!), '', ]
for (const category of sorted) { lines.push(`## ${category.title}`) lines.push('')
const items = [...(category.items || [])].sort((a, b) => (a.order || 100) - (b.order || 100)) for (const item of items) { const primaryLink = item.links?.[0]?.uri const name = primaryLink ? `[${item.name}](${primaryLink})` : item.name const desc = item.description ? ` — ${item.description}` : '' lines.push(`- **${name}**${desc}`)
const extraLinks = item.links?.slice(1) if (extraLinks?.length) { const linkStr = extraLinks.map(l => `[${l.label || 'Link'}](${l.uri})`).join(', ') lines.push(` ${linkStr}`) } }
lines.push('') }
return mdResponse(event, lines.join('\n'))})