diff --git a/.vscode/settings.json b/.vscode/settings.json index 63ac84fd..47c476a2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,6 @@ "files.trimTrailingWhitespace": true, "editor.codeActionsOnSave": { "source.organizeImports": true - } + }, + "editor.acceptSuggestionOnEnter": "on" } diff --git a/package-lock.json b/package-lock.json index 9188ef45..79cf8147 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.42.2", + "version": "1.42.3-watermark-fiare-issue.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.42.2", + "version": "1.42.3-watermark-fiare-issue.4", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index a8e6639e..2de20c2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.42.2", + "version": "1.42.3-watermark-fiare-issue.4", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", diff --git a/src/image-tags.js b/src/image-tags.js index 099a8f41..d084feb5 100644 --- a/src/image-tags.js +++ b/src/image-tags.js @@ -121,6 +121,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) { const imageCdnSrc = publisherConfig.cdn_src; const imageCdnUrl = publisherConfig.cdn_image || config["cdn-image"]; const fallbackSocialImage = get(seoConfig, ["fallbackSocialImage"]); + const watermarkImageS3Key = get(story, ["watermark", "social", "image-s3-key"], false); if (!image) { return []; @@ -137,10 +138,16 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) { const getWatermarkHeroImage = (imageRatio, imageProp) => { const overlayWatermarkProps = Object.assign({}, imageProp, { - overlay: getWatermarkImage(story, imageCdnSrc, imageCdnUrl), + overlay: getWatermarkImage(imageCdnSrc, imageCdnUrl, watermarkImageS3Key), overlay_position: "bottom", }); - + console.log( + "getWatermarkHeroImage LOGS 222:", + imageCdnSrc, + imageCdnUrl, + watermarkImageS3Key, + overlayWatermarkProps + ); const watermarkImageProps = imageCdnSrc && imageCdnSrc.includes("gumlet") ? Object.assign({}, overlayWatermarkProps, { @@ -160,7 +167,7 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) { return image; } }; - + console.log("includesHost LOGS 333:", fallbackSocialImage, getFallbackImage()); return includesHost ? getFallbackImage() : `https://${imageCdnUrl}/${image.path(imageRatio, watermarkImageProps)}`; }; @@ -173,7 +180,15 @@ export function ImageTags(seoConfig, config, pageType, data, { url = {} }) { mode: "crop", enlarge: true, }; - return isWatermarkDisabled ? getHeroImage(imageRatio, imageProp) : getWatermarkHeroImage(imageRatio, imageProp); + console.log( + "getImageContent LOGS 111:", + watermarkImageS3Key, + isWatermarkDisabled, + !watermarkImageS3Key || isWatermarkDisabled + ); + return !watermarkImageS3Key || isWatermarkDisabled + ? getHeroImage(imageRatio, imageProp) + : getWatermarkHeroImage(imageRatio, imageProp); }; if (seoConfig.enableTwitterCards) { diff --git a/src/utils.js b/src/utils.js index bd4c1977..6e5a2c91 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,5 +1,5 @@ import { format, utcToZonedTime } from "date-fns-tz"; -import { entries, get } from "lodash"; +import { entries } from "lodash"; import { URL, URLSearchParams } from "url"; export function objectToTags(object) { @@ -33,8 +33,7 @@ export function isStoryPublic(story) { return story.access === undefined || story.access === null || story.access === "public"; } -export function getWatermarkImage(story, cdnSrc, cdnURL) { - const watermarkImageS3Key = get(story, ["watermark", "social", "image-s3-key"], false); +export function getWatermarkImage(cdnSrc, cdnURL, watermarkImageS3Key) { if (cdnSrc && cdnSrc.includes("gumlet") && watermarkImageS3Key) { return `https://${cdnURL}/${watermarkImageS3Key}`; }