Skip to content

Commit 0636b7a

Browse files
yonicddaattali
authored andcommitted
Badge functionality to layout/post.html (daattali#265)
* add badges to default branch * add instructions in readme for post badges * update readme * add instructions for badges to readme yaml * switch GH badges to iframes and remove comment out cran badges * remove cran comment and update yaml table in readme file. * Update README.md * Update main.css
1 parent bbd747b commit 0636b7a

3 files changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ ext-js | List of external JavaScript files to include in the page (eg. `//c
147147
css | List of local CSS files to include in the page
148148
ext-css | List of external CSS files to include in the page. External CSS files using SRI (see `ext-js` parameter) are also supported.
149149
googlefonts | List of Google fonts to include in the page (eg. `["Monoton", "Lobster"]`)
150+
gh-repo   | If you want to show GitHub buttons at the top of a post, this sets the GitHub repo name (eg. `daattali/beautiful-jekyll`). You must also use the `gh-badge` parameter to specify what buttons to show.
151+
gh-badge | Select which GitHub buttons to display, available options are: [star, watch, fork, follow]. You must also use the `gh-repo` parameter to specify the GitHub repo.
150152

151153
### Advanced features (including how to use a custom URL address for your site)
152154

_layouts/post.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,29 @@
88
<div class="row">
99
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
1010

11+
{% if page.gh-repo %}
12+
{% assign gh_split = page.gh-repo | split:'/' %}
13+
{% assign gh_user = gh_split[0] %}
14+
{% assign gh_repo = gh_split[1] %}
15+
16+
<div id="header-gh-btns">
17+
{% if page.gh-badge.size > 0 %}
18+
{% for badge in page.gh-badge %}
19+
{% case badge %}
20+
{% when 'star'%}
21+
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=star&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
22+
{% when 'watch'%}
23+
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=watch&v=2&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
24+
{% when 'fork'%}
25+
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&repo={{ gh_repo }}&type=fork&count=true" frameborder="0" scrolling="0" width="120px" height="20px"></iframe>
26+
{% when 'follow'%}
27+
<iframe src="https://ghbtns.com/github-btn.html?user={{ gh_user }}&type=follow&count=true" frameborder="0" scrolling="0" width="220px" height="20px"></iframe>
28+
{% endcase %}
29+
{% endfor %}
30+
{% endif %}
31+
</div>
32+
{% endif %}
33+
1134
<article role="main" class="blog-post">
1235
{{ content }}
1336
</article>

css/main.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,16 @@ footer .theme-by {
589589
border-bottom-left-radius: 5px;
590590
}
591591

592+
#header-gh-btns {
593+
margin-bottom: 15px;
594+
}
595+
@media only screen and (max-width: 500px) {
596+
#header-gh-btns > iframe {
597+
display: block;
598+
margin-bottom: 5px;
599+
}
600+
}
601+
592602
/* --- Pager --- */
593603

594604
.pager li a {

0 commit comments

Comments
 (0)