Skip to content

Commit f93b8ca

Browse files
committed
Beautify the pin label on home page
1 parent d8c15b6 commit f93b8ca

File tree

6 files changed

+73
-43
lines changed

6 files changed

+73
-43
lines changed

_data/label.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
# © 2017-2019 Cotes Chung
55
# MIT Licensed
66

7-
87
panel:
9-
lastmod: "Recent Update"
10-
trending_tags: "Trending Tags"
11-
toc: "Contents"
8+
lastmod: Recent Update
9+
trending_tags: Trending Tags
10+
toc: Contents
1211

1312
post:
14-
relate_posts: "Further Reading"
13+
relate_posts: Further Reading
1514
button:
1615
next: Newer
1716
previous: Older
1817

19-
search_hint: "Search" # text show on search bar
18+
search_hint: Search # text show on search bar
19+
20+
pin_prompt: Pinned # pinned prompt

_layouts/home.html

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,46 @@
4949
{% for post in posts %}
5050

5151
<div class="post-preview">
52-
<div class="d-flex justify-content-between pr-xl-2">
53-
<h1><a href="{{ post.url | relative_url }}">{{ post.title }}</a></h1>
54-
{% if post.pin == true %}
55-
<i class="fas fa-thumbtack fa-fw text-muted mt-1 ml-2 mt-xl-2" data-toggle="tooltip" data-placement="left"
56-
title="Pinned"></i>
57-
{% endif %}
58-
</div>
52+
<a href="{{ post.url | relative_url }}">
53+
<h1>{{ post.title }}</h1>
54+
</a>
55+
5956
<div class="post-content">
6057
<p>
6158
{% include no-linenos.html content=post.content %}
6259
{{ content | markdownify | strip_html | truncate: 200 }}
6360
</p>
6461
</div>
6562

66-
<div class="post-meta text-muted">
67-
<!-- posted date -->
68-
<i class="far fa-calendar fa-fw"></i>
69-
{% include timeago.html date=post.date tooltip=true %}
70-
71-
<!-- time to read -->
72-
<i class="far fa-clock fa-fw"></i>
73-
<span>{% include read-time.html content=post.content %}</span>
74-
75-
<!-- page views -->
76-
{% if site.google_analytics.pv.enabled %}
77-
<i class="far fa-eye fa-fw"></i>
78-
<span id="pv_{{-post.title-}}" class="pageviews">
79-
<i class="fas fa-spinner fa-spin fa-fw"></i>
80-
</span>
63+
<div class="post-meta text-muted d-flex justify-content-between">
64+
65+
<div>
66+
<!-- posted date -->
67+
<i class="far fa-calendar fa-fw"></i>
68+
{% include timeago.html date=post.date tooltip=true %}
69+
70+
<!-- time to read -->
71+
<i class="far fa-clock fa-fw"></i>
72+
{% include read-time.html content=post.content %}
73+
74+
<!-- page views -->
75+
{% if site.google_analytics.pv.enabled %}
76+
<i class="far fa-eye fa-fw"></i>
77+
<span id="pv_{{-post.title-}}" class="pageviews">
78+
<i class="fas fa-spinner fa-spin fa-fw"></i>
79+
</span>
80+
{% endif %}
81+
</div>
82+
83+
{% if post.pin %}
84+
<div class="pin">
85+
<i class="fas fa-thumbtack fa-fw"></i>
86+
<span>{{ site.data.label.pin_prompt }}</span>
87+
</div>
8188
{% endif %}
8289

83-
</div>
90+
</div> <!-- .post-meta -->
91+
8492
</div> <!-- .post-review -->
8593

8694
{% endfor %}

assets/css/_colors/dark-typography.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
--btn-text-color: var(--text-color);
5252
--btn-paginator-border-color: var(--btn-border-color);
5353
--btn-paginator-shadow: var(--main-wrapper-bg);
54+
--pin-bg: rgb(34 35 37);
55+
--pin-color: iherit;
5456

5557
/* Posts */
5658
--toc-highlight: rgb(116, 178, 243);

assets/css/_colors/light-typography.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
--btn-text-color: #f8f8f8;
5454
--btn-paginator-border-color: #f1f1f1;
5555
--btn-paginator-shadow: #4b92d2;
56+
--pin-bg: #f5f5f5;
57+
--pin-color: #999fa4;
5658

5759
/* Posts */
5860
--btn-share-hover-color: var(--link-color);

assets/css/home.scss

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,22 @@
2020
h1 {
2121
font-size: 1.4rem;
2222
margin: 0;
23-
~i { // pinned icon
24-
font-size: 0.86rem;
25-
}
2623
}
2724

2825
.post-meta {
2926
i {
3027
font-size: 0.73rem;
31-
&:not(:first-child) { // post-meta icons on the homepage
32-
margin-left: 1rem;
33-
}
28+
}
29+
span:not(:last-child) {
30+
margin-right: 1.2rem;
3431
}
3532
}
3633

3734
.post-content {
3835
margin-top: 0.6rem;
3936
margin-bottom: 0.6rem;
4037
color: var(--post-list-text-color);
41-
>p {
38+
> p {
4239
/* Make preview shorter on the homepage */
4340
margin: 0;
4441
overflow: hidden;
@@ -49,6 +46,17 @@
4946
}
5047
}
5148

49+
.pin {
50+
> i {
51+
transform: rotate(45deg);
52+
padding-left: 3px;
53+
color: var(--pin-color);
54+
}
55+
> span {
56+
display: none;
57+
}
58+
}
59+
5260
} // .post-preview
5361

5462
} // #post-list
@@ -107,12 +115,6 @@
107115

108116
} // .pagination
109117

110-
@media all and (max-width: 576px) {
111-
#post-list .post-meta>span i:not(:first-child) {
112-
margin-left: 1rem;
113-
}
114-
}
115-
116118
/* Hide SideBar and TOC */
117119
@media all and (max-width: 830px) {
118120
.pagination {
@@ -125,6 +127,21 @@
125127

126128
#post-list {
127129
margin-top: 1.5rem;
130+
.post-preview .post-meta {
131+
.pin {
132+
background: var(--pin-bg);
133+
border-radius: 5px;
134+
line-height: 1.4rem;
135+
height: 1.3rem;
136+
margin-top: 3px;
137+
padding-left: 1px;
138+
padding-right: 6px;
139+
140+
> span {
141+
display: inline;
142+
}
143+
}
144+
}
128145
}
129146

130147
.pagination {

assets/js/_utils/pageviews.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function displayPageviews(data) {
145145

146146
if ($("#post-list").length > 0) { /* the Home page */
147147
$(".post-preview").each(function() {
148-
var path = $(this).children("div").children("h1").children("a").attr("href");
148+
var path = $(this).find("a").attr("href");
149149
tacklePV(rows, path, $(this).find(".pageviews"), hasInit);
150150
});
151151

0 commit comments

Comments
 (0)