From 7da3dff7d53bce931025a2eb597928b944116067 Mon Sep 17 00:00:00 2001 From: Vladimir Haltakov Date: Sat, 7 Feb 2026 22:26:16 +0100 Subject: [PATCH 1/4] fix: build recursive with empty folders without failing at the header image --- gallery/src/modules/build/index.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gallery/src/modules/build/index.ts b/gallery/src/modules/build/index.ts index 45725a1..6232f5c 100644 --- a/gallery/src/modules/build/index.ts +++ b/gallery/src/modules/build/index.ts @@ -172,16 +172,20 @@ async function buildGallery( } // Create the gallery social media card image - await createGallerySocialMediaCardImage(headerImagePath, galleryData.title, socialMediaCardImagePath, ui); + if (galleryData.headerImage) { + await createGallerySocialMediaCardImage(headerImagePath, galleryData.title, socialMediaCardImagePath, ui); - // Create optimized header image and generate blurhash - const { blurHash } = await createOptimizedHeaderImage(headerImagePath, imagesFolder, ui); + // Create optimized header image and generate blurhash + const { blurHash } = await createOptimizedHeaderImage(headerImagePath, imagesFolder, ui); - // Save the blurhash to gallery.json if it changed - if (galleryData.headerImageBlurHash !== blurHash) { - ui.debug('Updating gallery.json with header image blurhash'); - galleryData.headerImageBlurHash = blurHash; - fs.writeFileSync(galleryJsonPath, JSON.stringify(galleryData, null, 2)); + // Save the blurhash to gallery.json if it changed + if (galleryData.headerImageBlurHash !== blurHash) { + ui.debug('Updating gallery.json with header image blurhash'); + galleryData.headerImageBlurHash = blurHash; + fs.writeFileSync(galleryJsonPath, JSON.stringify(galleryData, null, 2)); + } + } else { + ui.warn('No header image provided, skipping social media card image creation'); } } From 93efbe0387cd1fa667f894aa68080991a1d0d3a1 Mon Sep 17 00:00:00 2001 From: Vladimir Haltakov Date: Sat, 7 Feb 2026 23:06:15 +0100 Subject: [PATCH 2/4] fix: subgallery thumbnails --- common/src/theme/paths.ts | 14 ++++++++------ common/src/theme/resolver.ts | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/src/theme/paths.ts b/common/src/theme/paths.ts index 338399d..d81c9a1 100644 --- a/common/src/theme/paths.ts +++ b/common/src/theme/paths.ts @@ -54,14 +54,16 @@ export function getPhotoPath(filename: string, mediaBaseUrl?: string, url?: stri /** * Get the path to a subgallery thumbnail that is always in the subgallery directory. * - * @param subgalleryHeaderImagePath - The path to the subgallery header image on the hard disk - * @returns The normalized path relative to the subgallery directory + * @param headerImageFilename - The filename of the subgallery header image + * @param resolvedSubgalleryPath - The resolved subgallery path relative to the gallery root + * @returns The normalized path relative to the gallery root directory */ -export function getSubgalleryThumbnailPath(subgalleryHeaderImagePath: string): string { - const photoBasename = path.basename(subgalleryHeaderImagePath); - const subgalleryFolderName = path.basename(path.dirname(subgalleryHeaderImagePath)); +export function getSubgalleryThumbnailPath(headerImageFilename: string, resolvedSubgalleryPath?: string): string { + const basename = path.basename(headerImageFilename, path.extname(headerImageFilename)); + const thumbnailFilename = `${basename}.avif`; + const subgalleryFolder = resolvedSubgalleryPath || path.basename(path.dirname(headerImageFilename)); - return path.join(subgalleryFolderName, 'gallery', 'thumbnails', photoBasename); + return path.join(subgalleryFolder, 'gallery', 'images', thumbnailFilename); } /** diff --git a/common/src/theme/resolver.ts b/common/src/theme/resolver.ts index 614f45a..27a4237 100644 --- a/common/src/theme/resolver.ts +++ b/common/src/theme/resolver.ts @@ -61,12 +61,13 @@ async function resolveSection( * Resolve a sub-gallery with computed thumbnail path and optional resolved path. */ function resolveSubGallery(subGallery: SubGallery, galleryJsonPath?: string): ResolvedSubGallery { + const resolvedPath = galleryJsonPath ? getRelativePath(subGallery.path, galleryJsonPath) : undefined; return { title: subGallery.title, headerImage: subGallery.headerImage, path: subGallery.path, - thumbnailPath: getSubgalleryThumbnailPath(subGallery.headerImage), - resolvedPath: galleryJsonPath ? getRelativePath(subGallery.path, galleryJsonPath) : undefined, + thumbnailPath: getSubgalleryThumbnailPath(subGallery.headerImage, resolvedPath), + resolvedPath, }; } From eac9755c0880185445c315144d089150312ba74b Mon Sep 17 00:00:00 2001 From: Vladimir Haltakov Date: Sat, 7 Feb 2026 23:07:46 +0100 Subject: [PATCH 3/4] chore: update the version to 2.1.4 --- common/package.json | 2 +- gallery/package.json | 6 +++--- .../modules/create-theme/templates/base/package.json | 2 +- themes/modern/package.json | 4 ++-- yarn.lock | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/package.json b/common/package.json index f1e9cc7..5cd0e96 100644 --- a/common/package.json +++ b/common/package.json @@ -1,6 +1,6 @@ { "name": "@simple-photo-gallery/common", - "version": "2.1.3", + "version": "2.1.4", "description": "Shared utilities and types for Simple Photo Gallery", "license": "MIT", "author": "Vladimir Haltakov, Tomasz Rusin", diff --git a/gallery/package.json b/gallery/package.json index 9743586..ecff5a5 100644 --- a/gallery/package.json +++ b/gallery/package.json @@ -1,6 +1,6 @@ { "name": "simple-photo-gallery", - "version": "2.1.3", + "version": "2.1.4", "description": "Simple Photo Gallery CLI", "license": "MIT", "author": "Vladimir Haltakov, Tomasz Rusin", @@ -47,8 +47,8 @@ "prepublish": "yarn build" }, "dependencies": { - "@simple-photo-gallery/common": "2.1.3", - "@simple-photo-gallery/theme-modern": "2.1.3", + "@simple-photo-gallery/common": "2.1.4", + "@simple-photo-gallery/theme-modern": "2.1.4", "axios": "^1.12.2", "blurhash": "^2.0.5", "commander": "^12.0.0", diff --git a/gallery/src/modules/create-theme/templates/base/package.json b/gallery/src/modules/create-theme/templates/base/package.json index f99bd4b..a315cdb 100644 --- a/gallery/src/modules/create-theme/templates/base/package.json +++ b/gallery/src/modules/create-theme/templates/base/package.json @@ -27,7 +27,7 @@ "photoswipe": "^5.4.4" }, "peerDependencies": { - "@simple-photo-gallery/common": "^2.1.3" + "@simple-photo-gallery/common": "^2.1.4" }, "devDependencies": { "@eslint/eslintrc": "^3.3.1", diff --git a/themes/modern/package.json b/themes/modern/package.json index e4f6bda..005bb68 100644 --- a/themes/modern/package.json +++ b/themes/modern/package.json @@ -1,6 +1,6 @@ { "name": "@simple-photo-gallery/theme-modern", - "version": "2.1.3", + "version": "2.1.4", "description": "Modern theme for Simple Photo Gallery", "license": "MIT", "author": "Vladimir Haltakov, Tomasz Rusin", @@ -36,7 +36,7 @@ "devDependencies": { "@eslint/eslintrc": "^3.3.1", "@eslint/js": "^9.30.1", - "@simple-photo-gallery/common": "2.1.3", + "@simple-photo-gallery/common": "2.1.4", "@types/photoswipe": "^4.1.6", "@typescript-eslint/eslint-plugin": "^8.35.1", "@typescript-eslint/parser": "^8.35.1", diff --git a/yarn.lock b/yarn.lock index f6db8ff..a2d53b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1652,7 +1652,7 @@ __metadata: languageName: node linkType: hard -"@simple-photo-gallery/common@npm:2.1.3, @simple-photo-gallery/common@workspace:common": +"@simple-photo-gallery/common@npm:2.1.4, @simple-photo-gallery/common@workspace:common": version: 0.0.0-use.local resolution: "@simple-photo-gallery/common@workspace:common" dependencies: @@ -1687,13 +1687,13 @@ __metadata: languageName: unknown linkType: soft -"@simple-photo-gallery/theme-modern@npm:2.1.3, @simple-photo-gallery/theme-modern@workspace:themes/modern": +"@simple-photo-gallery/theme-modern@npm:2.1.4, @simple-photo-gallery/theme-modern@workspace:themes/modern": version: 0.0.0-use.local resolution: "@simple-photo-gallery/theme-modern@workspace:themes/modern" dependencies: "@eslint/eslintrc": "npm:^3.3.1" "@eslint/js": "npm:^9.30.1" - "@simple-photo-gallery/common": "npm:2.1.3" + "@simple-photo-gallery/common": "npm:2.1.4" "@types/photoswipe": "npm:^4.1.6" "@typescript-eslint/eslint-plugin": "npm:^8.35.1" "@typescript-eslint/parser": "npm:^8.35.1" @@ -8570,8 +8570,8 @@ __metadata: dependencies: "@eslint/eslintrc": "npm:^3.3.1" "@eslint/js": "npm:^9.30.1" - "@simple-photo-gallery/common": "npm:2.1.3" - "@simple-photo-gallery/theme-modern": "npm:2.1.3" + "@simple-photo-gallery/common": "npm:2.1.4" + "@simple-photo-gallery/theme-modern": "npm:2.1.4" "@types/fs-extra": "npm:^11.0.4" "@types/jest": "npm:^30.0.0" "@types/node": "npm:^24.0.10" From 5724b7fef177d2bf6c89964e81d1bba09ab9955e Mon Sep 17 00:00:00 2001 From: Vladimir Haltakov Date: Sat, 7 Feb 2026 23:10:28 +0100 Subject: [PATCH 4/4] fix: don't generate social media card if there is no header image --- gallery/src/modules/build/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gallery/src/modules/build/index.ts b/gallery/src/modules/build/index.ts index 6232f5c..cb3b37a 100644 --- a/gallery/src/modules/build/index.ts +++ b/gallery/src/modules/build/index.ts @@ -240,8 +240,7 @@ async function buildGallery( } // Set the social media card URL if changed - - if (!galleryData.metadata.image) { + if (!galleryData.metadata.image && galleryData.headerImage) { ui.debug('Updating gallery.json with social media card URL'); galleryData.metadata.image = thumbsBaseUrl