From 9d21baf43bc261953758c555be0a86738fcf38c9 Mon Sep 17 00:00:00 2001 From: Nikita Karamov Date: Sun, 4 Feb 2024 15:23:05 +0100 Subject: [PATCH] Add Fediverse button Closes #107 --- CHANGELOG.md | 6 ++++++ README.md | 1 + index.html | 4 ++++ src/icons/fediverse.svg | 1 + src/shareon.css | 7 +++++++ src/shareon.js | 1 + 6 files changed, 20 insertions(+) create mode 100644 src/icons/fediverse.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b58c0..e7d8bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Fediverse button (via [Shareâ‚‚Fedi](https://github.com/kytta/share2fedi)) + ## [2.4.0] - 2023-12-07 ### Added diff --git a/README.md b/README.md index 82a8a98..9f7a49e 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ names of which match the names of the social networks (or `copy-url`, for the ```html
+ diff --git a/index.html b/index.html index 45935fd..c942681 100644 --- a/index.html +++ b/index.html @@ -30,6 +30,7 @@

<a>

+ @@ -54,6 +55,7 @@

<button>

+ @@ -83,6 +85,7 @@ data-text="hey check this out" > + @@ -106,6 +109,7 @@

Specimen

+ Toot diff --git a/src/icons/fediverse.svg b/src/icons/fediverse.svg new file mode 100644 index 0000000..92aba54 --- /dev/null +++ b/src/icons/fediverse.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/shareon.css b/src/shareon.css index 1964807..b099aad 100644 --- a/src/shareon.css +++ b/src/shareon.css @@ -92,6 +92,13 @@ background-image: url("icons/facebook.svg"); } +.shareon > .fediverse { + background-color: #8a54af; +} +.shareon > .fediverse:before { + background-image: url("icons/fediverse.svg"); +} + .shareon > .linkedin { background-color: #0a66c2; } diff --git a/src/shareon.js b/src/shareon.js index 63d75c5..b4a8f66 100644 --- a/src/shareon.js +++ b/src/shareon.js @@ -18,6 +18,7 @@ import "./shareon.css"; */ const urlBuilderMap = { facebook: (d) => `https://www.facebook.com/sharer/sharer.php?u=${d.url}${d.hashtags ? `&hashtag=%23${d.hashtags.split('%2C')[0]}` : ''}`, + fediverse: (d) => `https://s2f.kytta.dev/?text=${d.title}%0D%0A${d.url}${d.text ? `%0D%0A%0D%0A${d.text}` : ''}${d.via ? `%0D%0A%0D%0A${d.via}` : ''}`, email: (d) => `mailto:?subject=${d.title}&body=${d.url}`, linkedin: (d) => `https://www.linkedin.com/sharing/share-offsite/?url=${d.url}`, mastodon: (d) => `https://toot.kytta.dev/?text=${d.title}%0D%0A${d.url}${d.text ? `%0D%0A%0D%0A${d.text}` : ''}${d.via ? `%0D%0A%0D%0A${d.via}` : ''}`,