Added option to generate favicon

This commit is contained in:
Patrick Alvin Alcala 2025-09-18 12:55:08 +08:00
parent 29d02a0c5a
commit 1e3dc7ddad

View file

@ -2,6 +2,7 @@ import sharp from 'sharp'
interface Props {
size?: number
favicon?: boolean
}
const convertLogo = async (props: Props) => {
@ -16,6 +17,18 @@ const convertLogo = async (props: Props) => {
await sharp(webpBuffer).toFile(webpImage)
}
const generateFavicon = async (props: Props) => {
const inputSrc = 'src/assets/images/logo.png'
const favicon = 'public/favicon.png'
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(50).toBuffer()
await sharp(faviconBuffer).toFile(favicon)
}
export default (props: Props) => {
convertLogo(props)
if (props.favicon) {
generateFavicon(props)
}
}