mirror of
https://github.com/kremalicious/blog.git
synced 2024-06-28 16:48:00 +02:00
16 lines
435 B
TypeScript
16 lines
435 B
TypeScript
|
import type { APIRoute } from 'astro'
|
||
|
import sharp from 'sharp'
|
||
|
import ico from 'sharp-ico'
|
||
|
import path from 'node:path'
|
||
|
|
||
|
const faviconSrc = path.resolve('src/images/favicon.png')
|
||
|
|
||
|
export const GET: APIRoute = async () => {
|
||
|
const buffer = await sharp(faviconSrc).resize(32).toFormat('png').toBuffer()
|
||
|
const icoBuffer = ico.encode([buffer])
|
||
|
|
||
|
return new Response(icoBuffer, {
|
||
|
headers: { 'Content-Type': 'image/x-icon' }
|
||
|
})
|
||
|
}
|