From 39eafb173928a4be9af11ecd619733e30183d89d Mon Sep 17 00:00:00 2001 From: Kentai Radiquum Date: Sat, 22 Feb 2025 02:12:37 +0500 Subject: [PATCH] feat/generator: add sharing options --- generate/static/js/initGalleries.js | 49 +++++++++++++++++++++++++++++ generate/templates/YearPhotos.tsx | 12 +++++++ 2 files changed, 61 insertions(+) diff --git a/generate/static/js/initGalleries.js b/generate/static/js/initGalleries.js index c96180c..5fbaf86 100644 --- a/generate/static/js/initGalleries.js +++ b/generate/static/js/initGalleries.js @@ -98,6 +98,55 @@ galleries.forEach((item, idx) => { hash: true, customSlideName: true, mobileSettings: { controls: true, showCloseIcon: true, download: true }, + extraProps: [ + "redditText", + "bskyText", + "msText", + "redditShareUrl", + "bskyShareUrl", + "msShareUrl", + ], + additionalShareOptions: [ + { + selector: ".lg-share-reddit", + dropdownHTML: + '
  • Reddit
  • ', + generateLink: (galleryItem) => { + const url = + galleryItem.redditShareUrl || + encodeURIComponent(window.location.href); + const title = galleryItem.redditText; + const redditShareLink = `https://reddit.com/submit?url=${url}&title=${title}`; + return redditShareLink; + }, + }, + { + selector: ".lg-share-bsky", + dropdownHTML: + '
  • Bluesky
  • ', + generateLink: (galleryItem) => { + const url = + galleryItem.bskyShareUrl || + encodeURIComponent(window.location.href); + const title = galleryItem.bskyText; + const bskyShareLink = `https://bsky.app/intent/compose?text=${title}%20${url}`; + return bskyShareLink; + }, + }, + { + selector: ".lg-share-ms", + dropdownHTML: + '
  • Mastodon
  • ', + generateLink: (galleryItem) => { + const url = + galleryItem.msShareUrl || + encodeURIComponent(window.location.href); + const title = galleryItem.msText; + const msShareLink = `https://tootpick.org/#text=${title}%20${url}`; + return msShareLink; + }, + }, + ], }); } }); diff --git a/generate/templates/YearPhotos.tsx b/generate/templates/YearPhotos.tsx index ae1e87b..1aff731 100644 --- a/generate/templates/YearPhotos.tsx +++ b/generate/templates/YearPhotos.tsx @@ -46,6 +46,18 @@ export default function YearPhotos({ year, images }: YearPhotosProps) { data-download-url={image.image} data-type="image" data-tags={image.tags.join(",")} + data-facebook-text={image.alt || "Photo by @radiquum"} + data-pinterest-text={image.alt || "Photo by @radiquum"} + data-tweet-text={image.alt || "Photo by @radiquum"} + data-reddit-text={image.alt || "Photo by @radiquum"} + data-bsky-text={image.alt || "Photo by @radiquum.wah.su"} + data-ms-text={image.alt || "Photo by @radiquum@furry.engineer"} + data-facebook-share-url={image.image} + data-twitter-share-url={image.image} + data-pinterest-share-url={image.image} + data-reddit-share-url={image.image} + data-bsky-share-url={image.image} + data-ms-share-url={image.image} >