Skip to content

Commit b29903f

Browse files
Chaitanya-Shaharevgvassilev
authored andcommitted
Add blog post card
- add blog-post-card in includes - fix multiple authors in blog-post-card
1 parent cec6f18 commit b29903f

File tree

3 files changed

+52
-90
lines changed

3 files changed

+52
-90
lines changed

_includes/blog-post-card.html

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
<div class="well">
3+
<h3>{{ post.title }}</h3>
4+
<p>
5+
{% if post.author %}
6+
{% for author_name in post.author %}
7+
{% assign author = site.data.contributors | where: "name", author_name | first %}
8+
{% if author %}
9+
<a href="{{ author.name | replace: " ", "" | prepend: "/team/" }}">
10+
<img
11+
src="{% if author.photo %}{{ site.baseurl }}/images/team/{{ author.photo }}{% else %}{{ site.baseurl }}/images/team/defaultDP.png{% endif %}"
12+
alt="{{ author.name }}" style="
13+
width: 30px;
14+
height: 30px;
15+
border-radius: 50%;
16+
margin: 0;
17+
margin-top: 4px;
18+
margin-bottom: 4px;
19+
" />
20+
{{ author.name }}
21+
</a>
22+
{% if forloop.last == false %}, {% endif %}
23+
{% else %}
24+
{{ author_name }}
25+
{% endif %}
26+
{% endfor %}
27+
{% endif %}
28+
<span class="text-muted">
29+
• {{ post.date | date: "%b %d, %Y" }} • {{ post.content | number_of_words | divided_by: 200 | ceil }} min read
30+
</span>
31+
</p>
32+
<p>{{ post.excerpt | truncatewords: 50 }}</p>
33+
34+
35+
{% if post.tags and post.tags.size > 0 %}
36+
<p>
37+
{% for tag in post.tags %}
38+
<a href="{{ site.baseurl }}/tags#{{ tag | downcase | slugify }}" class="badge" style="background-color: #999999; padding: 0.5rem">{{ tag }}</a>
39+
{% endfor %}
40+
</p>
41+
{% endif %}
42+
43+
<p>
44+
<button class="btn btn-primary" onclick="window.location.href='{{ post.url }}'">Read More</button>
45+
</p>
46+
</div>

_layouts/blog.html

+1-43
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,5 @@
66
<h2>Latest Posts</h2>
77

88
<div>
9-
{% for post in site.posts %}
10-
<div class="well">
11-
<h3>{{ post.title }}</h3>
12-
<p>
13-
{% assign author = site.data.contributors | where: "name", post.author | first %}
14-
{% if author %}
15-
<a href="{{ author.name | replace: " ", "" | prepend: "/team/" }}">
16-
<img
17-
src="{% if author.photo %}{{ site.baseurl }}/images/team/{{ author.photo }}{% else %}{{ site.baseurl }}/images/team/defaultDP.png{% endif %}"
18-
alt="{{ author.name }}" style="
19-
width: 30px;
20-
height: 30px;
21-
border-radius: 50%;
22-
/* vertical-align: middle; */
23-
margin: 0;
24-
margin-top: 4px;
25-
margin-bottom: 4px;
26-
" />
27-
{{ author.name }}
28-
</a>
29-
{% else %}
30-
{{ post.author }}
31-
{% endif %}
32-
<span class="text-muted">
33-
• {{ post.date | date: "%b %d, %Y" }} • {{ post.content | number_of_words | divided_by: 200 | ceil }} min read
34-
</span>
35-
</p>
36-
<p>{{ post.excerpt | truncatewords: 50 }}</p>
37-
38-
39-
{% if post.tags and post.tags.size > 0 %}
40-
<p>
41-
{% for tag in post.tags %}
42-
<a href="{{ site.baseurl }}/tags#{{ tag | downcase | slugify }}" class="badge" style="background-color: #999999; padding: 0.5rem">{{ tag }}</a>
43-
{% endfor %}
44-
</p>
45-
{% endif %}
46-
47-
<p>
48-
<button class="btn btn-primary" onclick="window.location.href='{{ post.url }}'">Read More</button>
49-
</p>
50-
</div>
51-
{% endfor %}
9+
{% for post in site.posts %} {% include blog-post-card.html %} {% endfor %}
5210
</div>

_layouts/tags.html

+5-47
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,13 @@ <h2>Tags</h2>
77

88
<div>
99
{% for tag in site.tags %} {% assign t = tag | first %} {% assign posts = tag
10-
| last %}
10+
| last %}
1111

12-
<h3 id={{t | downcase}}>
13-
{{ t | downcase }}
14-
</h3>
12+
<h3 id="{{ t | downcase }}">{{ t | downcase }}</h3>
1513
<div>
16-
{% for post in posts %} {% if post.tags contains t %}
17-
<div class="well">
18-
<h3>{{ post.title }}</h3>
19-
<p>
20-
{% assign author = site.data.contributors | where: "name", post.author | first %}
21-
{% if author %}
22-
<a href="{{ author.name | replace: " ", "" | prepend: " /team/" }}">
23-
<img
24-
src="{% if author.photo %}{{ site.baseurl }}/images/team/{{ author.photo }}{% else %}{{ site.baseurl }}/images/team/defaultDP.png{% endif %}"
25-
alt="{{ author.name }}" style="
26-
width: 30px;
27-
height: 30px;
28-
border-radius: 50%;
29-
/* vertical-align: middle; */
30-
margin: 0;
31-
margin-top: 4px;
32-
margin-bottom: 4px;
33-
" />
34-
{{ author.name }}
35-
</a>
36-
{% else %}
37-
{{ post.author }}
38-
{% endif %}
39-
<span class="text-muted">
40-
• {{ post.date | date: "%b %d, %Y" }} • {{ post.content | number_of_words | divided_by: 200 | ceil }} min read
41-
</span>
42-
</p>
43-
<p>{{ post.excerpt | truncatewords: 50 }}</p>
44-
45-
{% if post.tags and post.tags.size > 0 %}
46-
<p>
47-
{% for tag in post.tags %}
48-
<a href="{{ site.baseurl }}/tags#{{ tag | downcase | slugify }}" class="badge" style="background-color: #999999; padding: 0.5rem">{{ tag }}</a>
49-
{% endfor %}
50-
</p>
51-
{% endif %}
52-
53-
54-
<p>
55-
<button class="btn btn-primary" onclick="window.location.href='{{ post.url }}'">Read More</button>
56-
</p>
57-
</div>
58-
{% endif %} {% endfor %}
14+
{% for post in posts %} {% if post.tags contains t %} {% include
15+
blog-post-card.html post=post %} {% endif %} {% endfor %}
5916
</div>
17+
<hr />
6018
{% endfor %}
6119
</div>

0 commit comments

Comments
 (0)