Skip to content

Commit

Permalink
Add button for Hacker News (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
kytta authored Nov 17, 2024
2 parents 177935e + 2aa7b58 commit c02d3c4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h2><code>&lt;a&gt;</code></h2>
<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>
Expand All @@ -56,6 +57,7 @@ <h2><code>&lt;button&gt;</code></h2>
<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>
Expand Down Expand Up @@ -86,6 +88,7 @@ <h2><code>&lt;a&gt;</code> with custom params</h2>
>
<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>
Expand All @@ -110,6 +113,7 @@ <h2>Specimen</h2>
<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>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/icons/hackernews.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/shareon.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/shareon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit c02d3c4

Please sign in to comment.