1
0
mirror of https://github.com/NickKaramoff/shareon synced 2025-02-08 07:38:52 +01:00

Add button for Hacker News (#132)

This commit is contained in:
Nikita Karamov 2024-11-17 19:25:29 +01:00 committed by GitHub
commit c02d3c4289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 16 additions and 3 deletions

View File

@ -4,7 +4,7 @@
> Lightweight, stylish, and ethical share buttons
- **Small.** Dependency-free. CSS+JS bundle is only 6 KB minified and brotlied.
- **Small.** Dependency-free. CSS+JS bundle is under 7.5 kB minified and brotlied.
- **Stylish.** Uses official vector logos and colours with no visual mess.
- **Ethical.** Embeds no tracking code. JS is required only for the setup.

View File

@ -31,6 +31,7 @@
<div class="shareon">
<a class="facebook"></a>
<a class="fediverse"></a>
<a class="hackernews"></a>
<a class="linkedin"></a>
<a class="mastodon"></a>
<a class="messenger" data-fb-app-id="3619024578167617"></a>
@ -56,6 +57,7 @@
<div class="shareon">
<button class="facebook"></button>
<button class="fediverse"></button>
<button class="hackernews"></button>
<button class="linkedin"></button>
<button class="mastodon"></button>
<button class="messenger" data-fb-app-id="3619024578167617"></button>
@ -86,6 +88,7 @@
>
<a class="facebook"></a>
<a class="fediverse" data-s2f-instance="share2fedi.vercel.app"></a>
<a class="hackernews"></a>
<a class="linkedin"></a>
<a class="mastodon" data-via="@NickKaramoff@fosstodon.org"></a>
<a class="messenger" data-fb-app-id="3619024578167617"></a>
@ -110,6 +113,7 @@
<div class="shareon specimen">
<a class="facebook"></a>
<a class="fediverse"></a>
<a class="hackernews"></a>
<a class="linkedin"></a>
<a class="mastodon">Toot</a>
<a class="messenger" data-fb-app-id="3619024578167617"></a>

View File

@ -110,12 +110,12 @@
},
"size-limit": [
{
"limit": "6 KiB",
"limit": "6.1 KiB",
"path": "./dist/shareon.min.css",
"brotli": true
},
{
"limit": "1 KiB",
"limit": "1.1 KiB",
"path": "./dist/shareon.es.js",
"brotli": true
}

1
src/icons/hackernews.svg Normal file
View File

@ -0,0 +1 @@
<svg fill="#fff" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m2.842.564 7.545 14.144V24h2.905v-9.124L20.903.566h-3.21L13.186 9.51c-.682 1.367-1.262 2.631-1.262 2.631s-.545-1.299-1.195-2.63L6.291.563z"/></svg>

After

Width:  |  Height:  |  Size: 228 B

View File

@ -99,6 +99,13 @@
background-image: url("icons/fediverse.svg");
}
.shareon > .hackernews {
background-color: #fb651e;
}
.shareon > .hackernews:before {
background-image: url("icons/hackernews.svg");
}
.shareon > .linkedin {
background-color: #0a66c2;
}

View File

@ -21,6 +21,7 @@ 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://${d.s2fInstance}/?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}`,
hackernews: (d) => `https://news.ycombinator.com/submitlink?u=${d.url}&t=${d.title}`,
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}` : ''}`,
messenger: (d) => `https://www.facebook.com/dialog/send?app_id=${d.fbAppId}&link=${d.url}&redirect_uri=${d.url}`,