feat: add full favicon support
This commit is contained in:
parent
c50855a5de
commit
9590e739b0
8 changed files with 44 additions and 10 deletions
17
src/pages/favicon.ico.js
Normal file
17
src/pages/favicon.ico.js
Normal 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' }
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue