Skip to content

Commit a5480c5

Browse files
Add post metadata on blog landing page (#197)
- Add author name and profile photo - Link author's name to authors profile page - Add Read More button - Add estimated time to read - Truncate excerpt to 50 words
1 parent 73aa12f commit a5480c5

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

Diff for: _layouts/blog.html

+34-7
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,41 @@
22
layout: default
33
title: Blog
44
---
5-
<h3>Latest Posts</h3>
5+
6+
<h2>Latest Posts</h2>
67

78
<div>
89
{% for post in site.posts %}
9-
<div class="well">
10-
<h3>{{ post.title }}</h3>
11-
{{ post.excerpt }}
12-
<p>Read more <a href="{{ post.url }}">here</a></p>
13-
</div>
14-
{% endfor %}
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+
<p>
38+
<button class="btn btn-primary" onclick="window.location.href='{{ post.url }}'">Read More</button>
39+
</p>
1540
</div>
41+
{% endfor %}
42+
</div>

Diff for: _layouts/post.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ <h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
1818
first %} {% assign author_link = author.name | replace: " ", "" |
1919
prepend: "/team/" %}
2020
<a href="{{ author_link }}" itemprop="url">
21-
{% if author.photo %}
2221
<img
23-
src="{{ site.baseurl }}/images/team/{{ author.photo }}"
22+
src="{% if author.photo %}{{ site.baseurl }}/images/team/{{ author.photo }}{% else %}{{ site.baseurl }}/images/team/defaultDP.png{% endif %}"
2423
alt="{{ author_name }}"
2524
class="author-image"
25+
style="margin: 0"
2626
/>
27-
{% endif %}
2827
<span itemprop="name">{{ author_name }}</span>
2928
</a>
3029
{% if forloop.last == false %} , {% endif %}

Diff for: _posts/2023-05-10-accelerated-documentation-with-google-season-of-docs-2023.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Automatic Differentiation applications (using Clad, e.g. in RooFit and
88
Floating-Point Error Estimation), and Python-C++ Interoperability (Clang-Repl
99
(LLVM), CppInterOp, cppyy, Numba, etc.)."
1010
sitemap: false
11-
author: QuillPusher (Saqib)
11+
author: QuillPusher
1212
permalink: blogs/gsod23_quillpusher_experience_blog/
1313
date: 2023-05-10
1414
---

Diff for: css/main.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ firstp {
211211
color: #fff; /* Custom Button text color */
212212
}
213213
// hover color for the custom button for Front Page, etc.
214-
.btn-primary:hover {
214+
.custom-btn:hover {
215215
background-color: #292929c7 !important; /* Custom Button hover color */
216216
}
217217

0 commit comments

Comments
 (0)