Skip to content

Commit 1eefd1d

Browse files
committed
Add author avatar to post hero from Github (if available)
1 parent 23635f6 commit 1eefd1d

File tree

4 files changed

+57
-21
lines changed

4 files changed

+57
-21
lines changed

_data/authors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ soorae:
2323

2424
theo:
2525
name: Théophane Rupin
26+
github: trupin
2627
about: |
2728
iOS Developer @Scribd. Creator of Weaver
2829

_includes/featured-post-hero.html

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% assign hero = page.hero %}
2-
<div class="feat-post">
2+
<div class="feat-post theme-white">
33
<div class="container">
44
<div class="feat-post__container">
55

@@ -15,19 +15,31 @@ <h2 class="hero__title">
1515
</h2>
1616

1717
<ul class="hero__meta">
18+
1819
<!-- Post Author -->
1920
{%- if post.author -%}
20-
<li class="hero__meta-item author">
21-
<strong>Author</strong><br>
22-
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
23-
<span itemprop="name">
24-
{%- if site.data.authors[post.author] -%}
25-
{{ site.data.authors[post.author].name}}
26-
{%- else -%}
27-
{{ post.author }}
28-
{%- endif -%}
21+
<li class="hero__meta-item author media">
22+
23+
<!-- Author Avatar -->
24+
{%- if site.data.authors[post.author].github -%}
25+
<img class="hero__meta-avatar"
26+
srcset="https://github.com/{{ site.data.authors[post.author].github}}.png?size=48,
27+
https://github.com/{{ site.data.authors[post.author].github}}.png?size=96 2x"
28+
src="https://github.com/{{ site.data.authors[post.author].github}}.png?size=48" role="presentation" alt="">
29+
{%- endif -%}
30+
31+
<div class="media-body">
32+
<strong>Author</strong><br>
33+
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
34+
<span itemprop="name">
35+
{%- if site.data.authors[post.author] -%}
36+
{{ site.data.authors[post.author].name}}
37+
{%- else -%}
38+
{{ post.author }}
39+
{%- endif -%}
40+
</span>
2941
</span>
30-
</span>
42+
</div>
3143
</li>
3244
{%- endif -%}
3345

_includes/post-hero.html

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,28 @@ <h1 class="hero__title" itemprop="name headline">{{ page.title | escape }}</h1>
1515

1616
<!-- Post Author -->
1717
{%- if page.author -%}
18-
<li class="hero__meta-item author">
19-
<strong>Author</strong><br>
20-
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
21-
<span itemprop="name">
22-
{%- if site.data.authors[page.author] -%}
23-
{{ site.data.authors[page.author].name}}
24-
{%- else -%}
25-
{{ page.author }}
26-
{%- endif -%}
18+
<li class="hero__meta-item author media">
19+
20+
<!-- Author Avatar -->
21+
{%- if site.data.authors[page.author].github -%}
22+
<img class="hero__meta-avatar"
23+
srcset="https://github.com/{{ site.data.authors[page.author].github}}.png?size=48,
24+
https://github.com/{{ site.data.authors[page.author].github}}.png?size=96 2x"
25+
src="https://github.com/{{ site.data.authors[page.author].github}}.png?size=48" role="presentation" alt="">
26+
{%- endif -%}
27+
28+
<div class="media-body">
29+
<strong>Author</strong><br>
30+
<span itemprop="author" itemscope itemtype="http://schema.org/Person">
31+
<span itemprop="name">
32+
{%- if site.data.authors[page.author] -%}
33+
{{ site.data.authors[page.author].name}}
34+
{%- else -%}
35+
{{ page.author }}
36+
{%- endif -%}
37+
</span>
2738
</span>
28-
</span>
39+
</div>
2940
</li>
3041
{%- endif -%}
3142

assets/_sass/component/_hero.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
grid-template-areas:
8787
"author author author"
8888
"published category .";
89+
align-items: center;
8990
margin: .5em 0 0 0;
9091
font-size: rem-calc(14px);
9192
@extend .list--plain;
@@ -119,3 +120,14 @@
119120
.hero__meta-item.author { grid-area: author }
120121
.hero__meta-item.published { grid-area: published }
121122
.hero__meta-item.category { grid-area: category }
123+
124+
.hero__meta-avatar {
125+
border-radius: 100%;
126+
max-width: 35px;
127+
margin-right: rem-calc(10px);
128+
129+
@media (min-width: $bp-sm) {
130+
max-width: 48px;
131+
margin-right: rem-calc(15px);
132+
}
133+
}

0 commit comments

Comments
 (0)