Release 2025-05-19

This commit is contained in:
pluja
2025-05-19 10:23:36 +00:00
parent 2657f936bc
commit 565e9a0ad1
267 changed files with 49417 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { ogImageTemplates } from '../components/OgImage'
import { urlParamsToObject } from '../lib/urls'
import type { APIRoute } from 'astro'
export const GET: APIRoute = ({ url }) => {
const { template, ...props } = urlParamsToObject(url.searchParams)
if (!template) return ogImageTemplates.default()
if (!(template in ogImageTemplates)) {
console.error(`Invalid template: "${template}"`)
return ogImageTemplates.default()
}
const response = ogImageTemplates[template as keyof typeof ogImageTemplates](props)
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!response) {
console.error(`Cannot generate image for template: ${template} and props: ${JSON.stringify(props)}`)
return ogImageTemplates.default()
}
return response
}