Skip to content

Commit

Permalink
Add social share buttons to posts
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankGoyens committed May 8, 2024
1 parent fde2ac3 commit 499521a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ linkedin_username: frank-goyens-093471105
linkedin_display_name: LinkedIn
blogspot_username: frankgoyens
google_analytics: G-S5S027CNC5
twitter_username: FrankGoyens
6 changes: 6 additions & 0 deletions _includes/share_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="share-page">
Share this on &rarr;
<a href="https://twitter.com/intent/tweet?text={{ page.title }}&url={{ site.url }}{{ page.url }}&via={{ site.twitter_username }}&related={{ site.twitter_username }}" rel="nofollow" target="_blank" title="Share on Twitter">Twitter</a>
<a href="https://facebook.com/sharer.php?u={{ site.url }}{{ page.url }}" rel="nofollow" target="_blank" title="Share on Facebook">Facebook</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url={{ site.url }}{{ page.url }}&title={{ page.title }}&summary={{ page.content | strip_html | truncatewords: 50 }}&source={{ site.url }}">LinkedIn</a>
</div>
27 changes: 27 additions & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
layout: default
---
<article class="post h-entry" itemscope itemtype="http://schema.org/BlogPosting">

<header class="post-header">
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
<p class="post-meta">
<time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">
{%- assign date_format = site.minima.date_format | default: "%b %-d, %Y" -%}
{{ page.date | date: date_format }}
</time>
{%- if page.author -%}
<span itemprop="author" itemscope itemtype="http://schema.org/Person"><span class="p-author h-card" itemprop="name">{{ page.author }}</span></span>
{%- endif -%}</p>
</header>

<div class="post-content e-content" itemprop="articleBody">
{{ content }}
</div>
{%- include share_page.html -%}
{%- if site.disqus.shortname -%}
{%- include disqus_comments.html -%}
{%- endif -%}

<a class="u-url" href="{{ page.url | relative_url }}" hidden></a>
</article>
16 changes: 16 additions & 0 deletions assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,19 @@
width: 30%;
}

.share-page {
text-align: center;
padding: 8px 15px;
border-radius: 5px;
margin: 1.5 * $spacing-unit 0;

a {
font-weight: 700;
color: #fff;
margin-left: 10px;

&:hover {
border-bottom: 1px dashed #fff;
}
}
}

0 comments on commit 499521a

Please sign in to comment.