diff --git a/prerender-single-product.cjs b/prerender-single-product.cjs
index 7afdbfb..9788079 100644
--- a/prerender-single-product.cjs
+++ b/prerender-single-product.cjs
@@ -88,6 +88,12 @@ const renderSingleProduct = async (productSeoName) => {
const productDetails = await fetchProductDetails(socket, productSeoName);
console.log(`📦 Product found: ${productDetails.product.name}`);
+ // Save product image to static files
+ if (productDetails.product) {
+ console.log(`📷 Saving product image...`);
+ await saveProductImages(socket, [productDetails.product], "Single Product", config.outputDir);
+ }
+
// Set up minimal global cache (empty for single product test)
global.window.productCache = {};
global.productCache = {};
diff --git a/src/components/Images.js b/src/components/Images.js
index 8855334..baca1b9 100644
--- a/src/components/Images.js
+++ b/src/components/Images.js
@@ -134,46 +134,56 @@ class Images extends Component {
);
}
- // SPA version - full functionality
+ // SPA version - full functionality with static fallback
+ const getImageSrc = () => {
+ // If dynamic image is loaded, use it
+ if (this.state.pics[this.state.mainPic]) {
+ return this.state.pics[this.state.mainPic];
+ }
+ // Otherwise, use static fallback (same as prerender)
+ if (!this.props.pictureList || !this.props.pictureList.trim()) {
+ return '/assets/images/nopicture.jpg';
+ }
+ return `/assets/images/prod${this.props.pictureList.split(',')[0].trim()}.jpg`;
+ };
+
return (
<>
- {this.state.pics[this.state.mainPic] && (
-
-
-
-
-
-
- )}
+
+
+
+
+
+
{this.state.pics.filter(pic => pic !== null && pic !== this.state.pics[this.state.mainPic]).map((pic, filterIndex) => {
// Find the original index in the full pics array