{/* Gallery padding */}
+
+ {rows.map((row, rowIndex) => {
+ const isOdd = rowIndex % 2 === 0;
+
+ return (
+
+ {row.map((src, colIndex) => {
+ const globalIndex = row.slice(0, colIndex).length + rows.slice(0, rowIndex).reduce((a, r) => a + r.length, 0);
+ const isLastImage = globalIndex === images.length - 1;
+
+ let widthClass = 'md:w-full';
+
+ if (isOdd) {
+ // 4-image row: wide-narrow-wide-narrow
+ if (row.length === 4) {
+ widthClass =
+ colIndex % 2 === 0 ? 'md:basis-[calc(33.33%-0.5rem)]' : 'md:basis-[calc(16.66%-0.5rem)]';
+ } else if (row.length === 3) {
+ widthClass = 'md:basis-[calc(33.33%-0.5rem)]';
+ } else if (row.length === 2) {
+ widthClass = 'md:basis-[calc(50%-0.5rem)]';
+ } else {
+ widthClass = 'md:basis-full';
+ }
+ } else {
+ // 3-image row: equal width
+ if (row.length === 3) {
+ widthClass = 'md:basis-[calc(33.33%-0.5rem)]';
+ } else if (row.length === 2) {
+ widthClass = 'md:basis-[calc(50%-0.5rem)]';
+ } else {
+ widthClass = 'md:basis-full';
+ }
+ }
+
+ return (
+
+
+ {isLastImage && (
+
+
+ View more →
+
+
+ )}
+
+ );
+ })}
+
+ );
+ })}
+
+ );
+};
+
+export default Gallery;
diff --git a/next.config.js b/next.config.js
index de81129a..65d9c428 100644
--- a/next.config.js
+++ b/next.config.js
@@ -13,6 +13,7 @@ const config = {
{ protocol: 'https', hostname: env.AWS_PUBLIC_S3_NAME },
{ protocol: 'https', hostname: env.AWS_PRIVATE_S3_NAME },
],
+ domains: ['images.unsplash.com'],
},
};