diff --git a/package.json b/package.json index e3a79b2..361cfa0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "start": "cross-env NODE_OPTIONS=\"--no-deprecation\" webpack serve --progress --mode development --no-open", "start:seedheads": "cross-env PROXY_TARGET=https://seedheads.de NODE_OPTIONS=\"--no-deprecation\" webpack serve --progress --mode development --no-open", "prod": "webpack serve --progress --mode production --no-client-overlay --no-client --no-web-socket-server --no-open --no-live-reload --no-hot --compress --no-devtool", - "build:client": "cross-env NODE_ENV=production webpack --progress --mode production && shx cp dist/index.html dist/index_template.html", + "build:client": "node scripts/convert-images-to-avif.cjs && cross-env NODE_ENV=production webpack --progress --mode production && shx cp dist/index.html dist/index_template.html", "build": "npm run build:client", "analyze": "cross-env ANALYZE=true NODE_ENV=production webpack --progress --mode production", "lint": "eslint src/**/*.{js,jsx}", diff --git a/prerender/data-fetching.cjs b/prerender/data-fetching.cjs index 652460f..3ec5344 100644 --- a/prerender/data-fetching.cjs +++ b/prerender/data-fetching.cjs @@ -152,7 +152,7 @@ const saveProductImages = async (socket, products, categoryName, outputDir) => { "public", "assets", "images", - "sh.png" + "sh.avif" ); // Ensure assets/images directory exists @@ -236,7 +236,7 @@ const saveProductImages = async (socket, products, categoryName, outputDir) => { fs.writeFileSync(imagePath, processedImageBuffer); console.log( - ` ✅ Applied centered inverted sh.png overlay to ${estimatedFilename}` + ` ✅ Applied centered inverted sh.avif overlay to ${estimatedFilename}` ); } catch (overlayError) { console.log( diff --git a/prerender/seo/category.cjs b/prerender/seo/category.cjs index 42beb24..68d274f 100644 --- a/prerender/seo/category.cjs +++ b/prerender/seo/category.cjs @@ -1,4 +1,12 @@ const generateCategoryJsonLd = (category, products = [], baseUrl, config) => { + // Category IDs to skip (seeds, plants, headshop items) + const skipCategoryIds = [689, 706, 709, 711, 714, 748, 749, 896, 710, 924, 923, 922, 921, 916, 278, 259, 258]; + + // Check if category ID is in skip list + if (category.id && skipCategoryIds.includes(parseInt(category.id))) { + return ''; + } + const categoryUrl = `${baseUrl}/Kategorie/${category.seoName}`; // Calculate price valid date (current date + 3 months) diff --git a/public/assets/images/cutlings.avif b/public/assets/images/cutlings.avif new file mode 100644 index 0000000..759fa16 Binary files /dev/null and b/public/assets/images/cutlings.avif differ diff --git a/public/assets/images/gg.avif b/public/assets/images/gg.avif new file mode 100644 index 0000000..f07fb2d Binary files /dev/null and b/public/assets/images/gg.avif differ diff --git a/public/assets/images/maps.avif b/public/assets/images/maps.avif new file mode 100644 index 0000000..32a88f0 Binary files /dev/null and b/public/assets/images/maps.avif differ diff --git a/public/assets/images/seeds.avif b/public/assets/images/seeds.avif new file mode 100644 index 0000000..bec760d Binary files /dev/null and b/public/assets/images/seeds.avif differ diff --git a/public/assets/images/sh.avif b/public/assets/images/sh.avif new file mode 100644 index 0000000..8be600d Binary files /dev/null and b/public/assets/images/sh.avif differ diff --git a/scripts/convert-images-to-avif.cjs b/scripts/convert-images-to-avif.cjs new file mode 100644 index 0000000..b3137a6 --- /dev/null +++ b/scripts/convert-images-to-avif.cjs @@ -0,0 +1,58 @@ +const sharp = require('sharp'); +const path = require('path'); +const fs = require('fs'); + +const imagesToConvert = [ + { src: 'sh.png', dest: 'sh.avif' }, + { src: 'seeds.jpg', dest: 'seeds.avif' }, + { src: 'cutlings.jpg', dest: 'cutlings.avif' }, + { src: 'gg.png', dest: 'gg.avif' }, + { src: 'maps.png', dest: 'maps.avif' } +]; + +const run = async () => { + const imagesDir = path.join(__dirname, '../public/assets/images'); + let hasError = false; + + for (const image of imagesToConvert) { + const inputPath = path.join(imagesDir, image.src); + const outputPath = path.join(imagesDir, image.dest); + + if (!fs.existsSync(inputPath)) { + console.warn(`⚠️ Input file not found: ${inputPath}`); + continue; + } + + // Check if output file exists and compare modification times + // Only convert if source is newer or destination doesn't exist + let shouldConvert = true; + if (fs.existsSync(outputPath)) { + const inputStat = fs.statSync(inputPath); + const outputStat = fs.statSync(outputPath); + if (inputStat.mtime <= outputStat.mtime) { + shouldConvert = false; + } + } + + if (shouldConvert) { + try { + await sharp(inputPath) + .toFormat('avif') + .toFile(outputPath); + console.log(`✅ Converted ${image.src} to ${image.dest}`); + } catch (error) { + console.error(`❌ Error converting ${image.src}:`, error.message); + hasError = true; + } + } else { + // Silent skip if already up to date to keep logs clean, or use verbose flag + // console.log(`Skipping ${image.src} (already up to date)`); + } + } + + if (hasError) { + process.exit(1); + } +}; + +run(); diff --git a/scripts/convert-logo-to-avif.js b/scripts/convert-logo-to-avif.js new file mode 100644 index 0000000..4586239 --- /dev/null +++ b/scripts/convert-logo-to-avif.js @@ -0,0 +1,26 @@ +const sharp = require('sharp'); +const path = require('path'); +const fs = require('fs'); + +const run = async () => { + const inputPath = path.join(__dirname, '../public/assets/images/sh.png'); + const outputPath = path.join(__dirname, '../public/assets/images/sh.avif'); + + if (!fs.existsSync(inputPath)) { + console.error('Input file not found:', inputPath); + process.exit(1); + } + + try { + await sharp(inputPath) + .toFormat('avif') + .toFile(outputPath); + console.log(`Successfully converted ${inputPath} to ${outputPath}`); + } catch (error) { + console.error('Error converting image:', error); + process.exit(1); + } +}; + +run(); + diff --git a/src/components/Content.js b/src/components/Content.js index 0357cf3..2fc233e 100644 --- a/src/components/Content.js +++ b/src/components/Content.js @@ -722,7 +722,7 @@ class Content extends Component { justifyContent: 'center' }}> Seeds Stecklinge { const allContentBoxes = { home: [ - { title: t('sections.seeds'), image: "/assets/images/seeds.jpg", bgcolor: "#e1f0d3", link: "/Kategorie/Seeds" }, - { title: t('sections.stecklinge'), image: "/assets/images/cutlings.jpg", bgcolor: "#e8f5d6", link: "/Kategorie/Stecklinge" } + { title: t('sections.seeds'), image: "/assets/images/seeds.avif", bgcolor: "#e1f0d3", link: "/Kategorie/Seeds" }, + { title: t('sections.stecklinge'), image: "/assets/images/cutlings.avif", bgcolor: "#e8f5d6", link: "/Kategorie/Stecklinge" } ], aktionen: [ { title: t('sections.oilPress'), image: "/assets/images/presse.jpg", bgcolor: "#e1f0d3", link: "/presseverleih" }, diff --git a/src/components/header/Logo.js b/src/components/header/Logo.js index bf6be19..078c56e 100644 --- a/src/components/header/Logo.js +++ b/src/components/header/Logo.js @@ -16,7 +16,7 @@ const Logo = () => { }} >