feat: add full favicon support

This commit is contained in:
grassblock 2025-06-04 18:17:29 +08:00
parent c50855a5de
commit 9590e739b0
8 changed files with 44 additions and 10 deletions

17
src/pages/favicon.ico.js Normal file
View file

@ -0,0 +1,17 @@
import sharp from 'sharp'
import ico from 'ico-endec'
import path from 'node:path'
// relative to project root
const faviconSrc = path.resolve('src/assets/favicon.svg')
export const GET = async () => {
// resize to 32px PNG
const buffer = await sharp(faviconSrc).resize(32).toFormat('png').toBuffer()
// generate ico
const icoBuffer = ico.encode([buffer])
return new Response(icoBuffer, {
headers: { 'Content-Type': 'image/x-icon' }
})
}