feat: manually generate ogi to speed up builds

This commit is contained in:
Cory Dransfeldt 2024-05-02 14:49:04 -07:00
parent 25cc2f9d77
commit 7b7ce22aad
No known key found for this signature in database
303 changed files with 87 additions and 114 deletions

View file

@ -1,30 +1,6 @@
import fs from 'fs'
import Image from '@11ty/eleventy-img'
import { minify } from 'terser'
export const svgToJpeg = () => {
const socialPreviewImagesDir = '_site/assets/img/social-preview/'
fs.readdir(socialPreviewImagesDir, (err, files) => {
if (!!files && files.length > 0) {
files.forEach((fileName) => {
if (fileName.endsWith('.svg')) {
let imageUrl = socialPreviewImagesDir + fileName
Image(imageUrl, {
formats: ['jpeg'],
outputDir: './' + socialPreviewImagesDir,
filenameFormat: function (id, src, width, format) {
let outputFileName = fileName.substring(0, fileName.length - 4)
return `${outputFileName}.${format}`
},
})
}
})
} else {
console.log('⚠ No social images found')
}
})
}
export const minifyJsComponents = async () => {
const jsComponentsDir = '_site/assets/scripts/components';
const files = fs.readdirSync(jsComponentsDir);

View file

@ -22,17 +22,6 @@ export default {
const replacement = '&'
return string.replace(pattern, replacement)
},
splitLines: (input, maxCharLength) => {
const parts = input.split(' ')
const lines = parts.reduce(function (acc, cur) {
if (!acc.length) return [cur]
let lastOne = acc[acc.length - 1]
if (lastOne.length + cur.length > maxCharLength) return [...acc, cur]
acc[acc.length - 1] = lastOne + ' ' + cur
return acc
}, [])
return lines
},
stripUtm: (string) => {
if (!string) return
return string.replace(utmPattern, '')