Moved files
This commit is contained in:
parent
0e6ed89a08
commit
39d01e7a55
12 changed files with 482 additions and 0 deletions
17
src/templates/components/Optimizer/OptimizeBackground.tsx
Normal file
17
src/templates/components/Optimizer/OptimizeBackground.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import sharp from 'sharp'
|
||||
|
||||
const convertBackground = async () => {
|
||||
const inputSrc = 'src/assets/images/background.png'
|
||||
const webpOutput = 'src/templates/images/background.webp'
|
||||
const avifOutput = 'src/templates/images/background.avif'
|
||||
|
||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(1920).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifOutput)
|
||||
|
||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(1920).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpOutput)
|
||||
}
|
||||
|
||||
export default () => {
|
||||
convertBackground()
|
||||
}
|
||||
22
src/templates/components/Optimizer/OptimizeLogo.tsx
Normal file
22
src/templates/components/Optimizer/OptimizeLogo.tsx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import sharp from 'sharp'
|
||||
|
||||
interface Props {
|
||||
size?: number
|
||||
alt?: string
|
||||
}
|
||||
|
||||
const convertLogo = async (props: Props) => {
|
||||
const inputSrc = 'src/assets/images/logo.png'
|
||||
const webpImage = 'src/templates/images/logo.webp'
|
||||
const avifImage = 'src/templates/images/logo.avif'
|
||||
|
||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(props.size).toBuffer()
|
||||
await sharp(avifBuffer).toFile(avifImage)
|
||||
|
||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(props.size).toBuffer()
|
||||
await sharp(webpBuffer).toFile(webpImage)
|
||||
}
|
||||
|
||||
export default (props: Props) => {
|
||||
convertLogo(props)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue