Skip to content

Commit 8cee0d7

Browse files
Refactoring post-meta-divider (#937)
1 parent 65ead78 commit 8cee0d7

File tree

2 files changed

+53
-78
lines changed

2 files changed

+53
-78
lines changed

layout/_macro/post.swig

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
{% endif %}
6767

6868
<div class="post-meta">
69-
<span class="post-time">
7069

71-
{% set date_diff = date(post.date) != date(post.updated) %}
72-
{% set time_diff = time(post.date) != time(post.updated) %}
73-
{% set datetime_diff = date_diff or time_diff %}
70+
{% set date_diff = date(post.date) != date(post.updated) %}
71+
{% set time_diff = time(post.date) != time(post.updated) %}
72+
{% set datetime_diff = date_diff or time_diff %}
7473

75-
{% if theme.post_meta.created_at %}
74+
{% if theme.post_meta.created_at %}
75+
<span class="post-meta-item">
7676
<span class="post-meta-item-icon">
7777
<i class="fa fa-calendar-o"></i>
7878
</span>
@@ -89,16 +89,14 @@
8989
<time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{#
9090
#}{{ date(post.date) -}}
9191
</time>
92-
{% endif %}
93-
94-
{% if theme.post_meta.updated_at.enable && datetime_diff %}
95-
{% set display_updated = !theme.post_meta.updated_at.another_day || theme.post_meta.updated_at.another_day && date_diff %}
92+
</span>
93+
{% endif %}
9694

97-
{% if display_updated or !theme.post_meta.created_at %}
98-
{% if theme.post_meta.created_at and theme.post_meta.updated_at.enable %}
99-
<span class="post-meta-divider">|</span>
100-
{% endif %}
95+
{% if theme.post_meta.updated_at.enable && datetime_diff %}
96+
{% set display_updated = !theme.post_meta.updated_at.another_day || theme.post_meta.updated_at.another_day && date_diff %}
10197

98+
{% if display_updated or !theme.post_meta.created_at %}
99+
<span class="post-meta-item">
102100
<span class="post-meta-item-icon">
103101
<i class="fa fa-calendar-check-o"></i>
104102
</span>
@@ -108,15 +106,12 @@
108106
<time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{#
109107
#}{{ date(post.updated) -}}
110108
</time>
111-
{% endif %}
109+
</span>
112110
{% endif %}
113-
</span>
111+
{% endif %}
114112

115113
{% if post.categories and post.categories.length and theme.post_meta.categories %}
116-
<span class="post-category">
117-
{% if theme.post_meta.created_at or theme.post_meta.updated_at %}
118-
<span class="post-meta-divider">|</span>
119-
{% endif %}
114+
<span class="post-meta-item">
120115
<span class="post-meta-item-icon">
121116
<i class="fa fa-folder-o"></i>
122117
</span>
@@ -140,8 +135,7 @@
140135

141136
{% if post.comments %}
142137
{% macro comments() %}
143-
<span class="post-comments-count">
144-
<span class="post-meta-divider">|</span>
138+
<span class="post-meta-item">
145139
<span class="post-meta-item-icon">
146140
<i class="fa fa-comment-o"></i>
147141
</span>
@@ -192,8 +186,7 @@
192186

193187
{# LeanCloud PageView #}
194188
{% if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
195-
<span id="{{ url_for(post.path) }}" class="leancloud_visitors" data-flag-title="{{ post.title }}">
196-
<span class="post-meta-divider">|</span>
189+
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}">
197190
<span class="post-meta-item-icon">
198191
<i class="fa fa-eye"></i>
199192
</span>
@@ -205,49 +198,43 @@
205198
{% endif %}
206199

207200
{% if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
208-
<span class="post-meta-divider">|</span>
209-
<span class="post-meta-item-icon"
210-
{% if not theme.post_meta.item_text %} title="{{ __('post.views') }}" {% endif %}>
211-
<i class="fa fa-{{ theme.busuanzi_count.post_views_icon }}"></i>
212-
{% if theme.post_meta.item_text %} {{ __('post.views') + __('symbol.colon') }} {% endif %}
213-
<span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
201+
<span class="post-meta-item">
202+
<span class="post-meta-item-icon"
203+
{% if not theme.post_meta.item_text %} title="{{ __('post.views') }}" {% endif %}>
204+
<i class="fa fa-{{ theme.busuanzi_count.post_views_icon }}"></i>
205+
{% if theme.post_meta.item_text %} {{ __('post.views') + __('symbol.colon') }} {% endif %}
206+
<span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
207+
</span>
214208
</span>
215209
{% endif %}
216210

217-
{% if config.symbols_count_time.symbols or config.symbols_count_time.time %}
218-
<div class="post-symbolscount">
219-
{% if not theme.symbols_count_time.separated_meta %}
220-
<span class="post-meta-divider">|</span>
221-
{% endif %}
222-
223-
{% if config.symbols_count_time.symbols %}
224-
<span class="post-meta-item-icon">
225-
<i class="fa fa-file-word-o"></i>
226-
</span>
227-
{% if theme.symbols_count_time.item_text_post %}
228-
<span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
229-
{% endif %}
230-
<span title="{{ __('symbols_count_time.count') }}">{#
231-
#}{{ symbolsCount(post) }}{#
232-
#}</span>
233-
{% endif %}
234-
235-
{% if config.symbols_count_time.symbols and config.symbols_count_time.time %}
236-
<span class="post-meta-divider">|</span>
211+
{% if theme.symbols_count_time.separated_meta %}<br/>{% endif %}
212+
{% if config.symbols_count_time.symbols %}
213+
<span class="post-meta-item">
214+
<span class="post-meta-item-icon">
215+
<i class="fa fa-file-word-o"></i>
216+
</span>
217+
{% if theme.symbols_count_time.item_text_post %}
218+
<span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
237219
{% endif %}
220+
<span title="{{ __('symbols_count_time.count') }}">{#
221+
#}{{ symbolsCount(post) }}{#
222+
#}</span>
223+
</span>
224+
{% endif %}
238225

239-
{% if config.symbols_count_time.time %}
240-
<span class="post-meta-item-icon">
241-
<i class="fa fa-clock-o"></i>
242-
</span>
243-
{% if theme.symbols_count_time.item_text_post %}
244-
<span class="post-meta-item-text">{{ __('symbols_count_time.time') }} &asymp;</span>
245-
{% endif %}
246-
<span title="{{ __('symbols_count_time.time') }}">{#
247-
#}{{ symbolsTime(post, theme.symbols_count_time.awl, theme.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}{#
248-
#}</span>
226+
{% if config.symbols_count_time.time %}
227+
<span class="post-meta-item">
228+
<span class="post-meta-item-icon">
229+
<i class="fa fa-clock-o"></i>
230+
</span>
231+
{% if theme.symbols_count_time.item_text_post %}
232+
<span class="post-meta-item-text">{{ __('symbols_count_time.time') }} &asymp;</span>
249233
{% endif %}
250-
</div>
234+
<span title="{{ __('symbols_count_time.time') }}">{#
235+
#}{{ symbolsTime(post, theme.symbols_count_time.awl, theme.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}{#
236+
#}</span>
237+
</span>
251238
{% endif %}
252239

253240
{% if post.description and (not theme.excerpt_description or not is_index) %}

source/css/_common/components/post/post-meta.styl

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
font-size: 12px;
66
text-align: center;
77

8-
.post-category-list {
9-
display: inline-block;
10-
margin: 0;
11-
padding: 3px;
12-
}
13-
.post-category-list-link { color: $grey-dark; }
14-
158
.post-description {
169
font-size: 14px;
1710
margin-top: 2px;
@@ -23,29 +16,24 @@
2316
}
2417
}
2518

26-
.post-symbolscount {
27-
if !hexo-config('symbols_count_time.separated_meta') { display: inline-block; }
19+
.post-meta-divider {
20+
margin: 0 .5em;
2821
}
2922

30-
.post-meta-divider {
23+
.post-meta .post-meta-item + .post-meta-item::before {
24+
content: "|";
3125
margin: 0 .5em;
3226
}
3327

3428
.post-meta-item-icon {
3529
margin-right: 3px;
36-
+tablet() {
37-
display: inline-block;
38-
}
39-
+mobile() {
30+
+tablet-mobile() {
4031
display: inline-block;
4132
}
4233
}
4334

4435
.post-meta-item-text {
45-
+tablet() {
46-
hide();
47-
}
48-
+mobile() {
36+
+tablet-mobile() {
4937
hide();
5038
}
5139
}

0 commit comments

Comments
 (0)