|
|
@ -1,4 +1,5 @@ |
|
|
|
import type { APIRoute } from 'astro'; |
|
|
|
import type { APIRoute } from 'astro'; |
|
|
|
|
|
|
|
import { getDefaultOpenGraphImageBuffer } from '../../lib/open-graph'; |
|
|
|
|
|
|
|
|
|
|
|
export const prerender = false; |
|
|
|
export const prerender = false; |
|
|
|
|
|
|
|
|
|
|
@ -10,26 +11,22 @@ export const GET: APIRoute<any, Params> = async (context) => { |
|
|
|
const { slug } = context.params; |
|
|
|
const { slug } = context.params; |
|
|
|
|
|
|
|
|
|
|
|
if (!slug.startsWith('user-')) { |
|
|
|
if (!slug.startsWith('user-')) { |
|
|
|
return new Response( |
|
|
|
const buffer = await getDefaultOpenGraphImageBuffer(); |
|
|
|
JSON.stringify({ |
|
|
|
return new Response(buffer, { |
|
|
|
error: 'Invalid slug', |
|
|
|
headers: { |
|
|
|
}), |
|
|
|
'Content-Type': 'image/png', |
|
|
|
{ |
|
|
|
|
|
|
|
status: 400, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const username = slug.replace('user-', ''); |
|
|
|
const username = slug.replace('user-', ''); |
|
|
|
if (!username) { |
|
|
|
if (!username) { |
|
|
|
return new Response( |
|
|
|
const buffer = await getDefaultOpenGraphImageBuffer(); |
|
|
|
JSON.stringify({ |
|
|
|
return new Response(buffer, { |
|
|
|
error: 'Invalid username', |
|
|
|
headers: { |
|
|
|
}), |
|
|
|
'Content-Type': 'image/png', |
|
|
|
{ |
|
|
|
|
|
|
|
status: 400, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const response = await fetch( |
|
|
|
const response = await fetch( |
|
|
|