Skip to content

Commit

Permalink
Allow overwriting of sharing links
Browse files Browse the repository at this point in the history
This PR changes this by grouping the links within an object key: `Site.Data.sharing.links`. This means that sites can provide their own
`data/sharing.json` file and overwrite the `links` key, to provide links of their own links.
  • Loading branch information
chrisbanes authored Nov 14, 2022
1 parent 12471e0 commit cc1c2d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
60 changes: 31 additions & 29 deletions data/sharing.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"email": {
"icon": "email",
"title": "sharing.email",
"url": "mailto:?body=%s&subject=%s"
},
"facebook": {
"icon": "facebook",
"title": "sharing.facebook",
"url": "https://www.facebook.com/sharer/sharer.php?u=%s&quote=%s"
},
"linkedin": {
"icon": "linkedin",
"title": "sharing.linkedin",
"url": "https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s"
},
"pinterest": {
"icon": "pinterest",
"title": "sharing.pinterest",
"url": "https://pinterest.com/pin/create/bookmarklet/?url=%s&description=%s"
},
"reddit": {
"icon": "reddit",
"title": "sharing.reddit",
"url": "https://reddit.com/submit/?url=%s&resubmit=true&title=%s"
},
"twitter": {
"icon": "twitter",
"title": "sharing.twitter",
"url": "https://twitter.com/intent/tweet/?url=%s&text=%s"
"links": {
"email": {
"icon": "email",
"title": "sharing.email",
"url": "mailto:?body=%s&subject=%s"
},
"facebook": {
"icon": "facebook",
"title": "sharing.facebook",
"url": "https://www.facebook.com/sharer/sharer.php?u=%s&quote=%s"
},
"linkedin": {
"icon": "linkedin",
"title": "sharing.linkedin",
"url": "https://www.linkedin.com/shareArticle?mini=true&url=%s&title=%s"
},
"pinterest": {
"icon": "pinterest",
"title": "sharing.pinterest",
"url": "https://pinterest.com/pin/create/bookmarklet/?url=%s&description=%s"
},
"reddit": {
"icon": "reddit",
"title": "sharing.reddit",
"url": "https://reddit.com/submit/?url=%s&resubmit=true&title=%s"
},
"twitter": {
"icon": "twitter",
"title": "sharing.twitter",
"url": "https://twitter.com/intent/tweet/?url=%s&text=%s"
}
}
}
5 changes: 2 additions & 3 deletions layouts/partials/sharing-links.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{{ with .Params.sharingLinks | default (.Site.Params.article.sharingLinks | default false) }}
{{ $links := site.Data.sharing }}
<section class="flex flex-row flex-wrap justify-center pt-4 text-xl">
{{ range . }}
{{ with index $links . }}
{{ range $.Site.Data.sharing.links }}
{{ with . }}
<a
class="m-1 inline-block min-w-[2.4rem] rounded bg-neutral-300 p-1 text-center text-neutral-700 hover:bg-primary-500 hover:text-neutral dark:bg-neutral-700 dark:text-neutral-300 dark:hover:bg-primary-400 dark:hover:text-neutral-800"
href="{{ printf .url $.Permalink $.Title }}"
Expand Down

0 comments on commit cc1c2d7

Please sign in to comment.