website backgrounds: make it easy to force a bg for a service

rework a bit the backgrounds transformation script so that we can later
easily force a specific background for a specific service. This comes
from a request from france-transfert but they changed their mind in the
end. Felt like the logic is good to keep for later though.
This commit is contained in:
Emmanuel Pelletier
2024-05-24 11:02:04 +02:00
parent 7ec0a278b4
commit e083128b05
46 changed files with 10 additions and 3 deletions

View File

@@ -23,8 +23,9 @@ async function resizeSourceBackgrounds() {
const backgrounds = await readdir(sourcesDir)
backgrounds.forEach((backgroundFile, i) => {
const srcPath = path.join(sourcesDir, backgroundFile)
const jpegPath = path.join(outputDir, `${i}.jpg`)
const avifPath = path.join(outputDir, `${i}.avif`)
const backgroundName = path.parse(backgroundFile).name
const jpegPath = path.join(outputDir, `${backgroundName}.jpg`)
const avifPath = path.join(outputDir, `${backgroundName}.avif`)
const image = sharp(srcPath)
.resize(1920, 1200, { fit: "cover" })