Apply suggestions from code review

Remove `hashtag` but use the first element of `hastags` instead for facebook hashtag parameter.

Co-authored-by: Nikita Karamov <me@kytta.dev>
pull/60/head
Edward 2023-07-06 20:50:57 +08:00 committed by GitHub
parent c00e449749
commit 59ba22638a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -17,7 +17,7 @@ import "./shareon.css";
* }) => string}} * }) => string}}
*/ */
const urlBuilderMap = { const urlBuilderMap = {
facebook: (d) => `https://www.facebook.com/sharer/sharer.php?u=${d.url}${d.hashtag? `&hashtag=#${d.hashtag}` : ''}`, facebook: (d) => `https://www.facebook.com/sharer/sharer.php?u=${d.url}${d.hashtags? `&hashtag=#${d.hashtags.split(',')[0]}` : ''}`,
linkedin: (d) => `https://www.linkedin.com/sharing/share-offsite/?url=${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}` : ''}`, 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}`, messenger: (d) => `https://www.facebook.com/dialog/send?app_id=${d.fbAppId}&link=${d.url}&redirect_uri=${d.url}`,
@ -85,11 +85,8 @@ const init = () => {
via: encodeURIComponent( via: encodeURIComponent(
child.dataset.via || container.dataset.via || "" child.dataset.via || container.dataset.via || ""
), ),
hashtag: encodeURIComponent(
child.dataset.hashtag || container.dataset.hashtag || ""
),
hashtags: encodeURIComponent( hashtags: encodeURIComponent(
child.dataset.hashtags?.replaceAll(', ', ',') || container.dataset.hashtags?.replaceAll(', ', ',') || "" child.dataset.hashtags || container.dataset.hashtags || ""
), ),
fbAppId: encodeURIComponent( fbAppId: encodeURIComponent(
child.dataset.fbAppId || container.dataset.fbAppId || "" child.dataset.fbAppId || container.dataset.fbAppId || ""