Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 8 additions & 6 deletions common/src/theme/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions common/src/theme/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
6 changes: 3 additions & 3 deletions gallery/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 13 additions & 10 deletions gallery/src/modules/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -236,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions themes/modern/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Loading