A steady horizon and large forms keep the view open.
#!/usr/bin/env node
/**
* Cleans up any leftover .jpg references in Nature collection HTML files,
* rewriting them to the matching .avif in /printables/img/nature-landscapes/.
*/
import fs from 'fs';
import path from 'path';
const targetDir = process.argv[2];
if (!targetDir) {
console.error('Usage: node fix-nature-jpg-to-avif-cleanup.js ');
process.exit(1);
}
const jpgRegex = /(["'(=]\s*\/printables\/img\/(?:classic|nature-landscapes)\/)([^"'\s)]+)\.jpg/gi;
function processFile(filePath) {
let content = fs.readFileSync(filePath, 'utf8');
const original = content;
const baseName = path.basename(filePath, '.html');
// Replace occurrences like /printables/img/classic/...jpg or /nature-landscapes/...jpg
content = content.replace(jpgRegex, (match, prefix, namePart) => {
// Always map to the nature-landscapes .avif version
return prefix + namePart + '.avif';
});
if (content !== original) {
fs.writeFileSync(filePath, content, 'utf8');
console.log(`✅ Cleaned .jpg references in: ${path.basename(filePath)}`);
}
}
const files = fs.readdirSync(targetDir);
for (const f of files) {
if (f.endsWith('.html')) {
processFile(path.join(targetDir, f));
}
}
console.log('🎉 Done cleaning leftover .jpg references in Nature HTML files.');