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.
123456789101112131415161718192021222324252627282930313233343536373839import { IncomingMessage } from 'http'
import { getMatchOrReturn } from '../scripts/global.mjs'
import { metadata } from './metadata.json'
export interface ParsedReqs { title: string date: string tags: string[]}
export function parseReqs(req: IncomingMessage) { const slug = getMatchOrReturn(req.url || '', /\/([^/]*).jpg$/, 1)
if (slug === 'og') { return { date: '', title: 'roe.dev', tags: [], } } const { title, date, tags = [] } = (metadata as Record<string, any>)[slug]
if (!title || !date) { throw new Error('No data found.') }
const parsedReqs: ParsedReqs = { date, title, tags, }
console.log(JSON.stringify(parsedReqs))
return parsedReqs}