forked from theme-next/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.swig
259 lines (227 loc) · 11 KB
/
post.swig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
{##################}
{### POST BLOCK ###}
{##################}
<article itemscope itemtype="http://schema.org/Article" class="post-block" lang="{{ post.lang or config.language }}">
<link itemprop="mainEntityOfPage" href="{{ post.permalink }}">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="{{ url_for(theme.avatar.url or theme.images + '/avatar.gif') }}">
<meta itemprop="name" content="{{ author }}">
<meta itemprop="description" content="{{ description }}">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="{{ title }}">
</span>
{%- if post.header !== false %}
<header class="post-header">
<{%- if is_index %}h2{% else %}h1{%- endif %} class="post-title{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="name headline">
{# Link posts #}
{%- if post.link %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{%- set postTitleIcon = '<i class="fa fa-external-link-alt"></i>' %}
{%- set postText = post.title or post.link %}
{{ next_url(post.link, postText + postTitleIcon, {class: 'post-title-link post-title-link-external', itemprop: 'url'}) }}
{% elif is_index %}
{%- if post.sticky > 0 %}
<span class="post-sticky-flag" title="{{ __('post.sticky') }}">
<i class="fa fa-thumbtack"></i>
</span>
{%- endif %}
{{ next_url(post.path, post.title or __('post.untitled'), {class: 'post-title-link', itemprop: 'url'}) }}
{%- else %}
{{- post.title }}
{{- post_edit(post.source) }}
{%- endif %}
</{%- if is_index %}h2{% else %}h1{%- endif %}>
<div class="post-meta">
{%- set date_diff = date(post.date) != date(post.updated) %}
{%- set time_diff = time(post.date) != time(post.updated) %}
{%- set datetime_diff = date_diff or time_diff %}
{%- if theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">{{ __('post.posted') }}</span>
{%- if not date_diff and time_diff and theme.post_meta.updated_at.enable and theme.post_meta.updated_at.another_day %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) + ' / ' + __('post.modified') + __('symbol.colon') + time(post.updated) %}
{% else %}
{%- set create_title = __('post.created') + __('symbol.colon') + full_date(post.date) %}
{%- endif %}
<time title="{{ create_title }}" itemprop="dateCreated datePublished" datetime="{{ moment(post.date).format() }}">{{ date(post.date) }}</time>
</span>
{%- endif %}
{%- if theme.post_meta.updated_at.enable and datetime_diff %}
{%- set display_updated = not theme.post_meta.updated_at.another_day or theme.post_meta.updated_at.another_day and date_diff %}
{%- if display_updated or not theme.post_meta.created_at %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">{{ __('post.edited') }}</span>
<time title="{{ __('post.modified') + __('symbol.colon') + full_date(post.updated) }}" itemprop="dateModified" datetime="{{ moment(post.updated).format() }}">{{ date(post.updated) }}</time>
</span>
{%- endif %}
{%- endif %}
{%- if post.categories and post.categories.length and theme.post_meta.categories %}
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">{{ __('post.in') }}</span>
{%- for cat in post.categories.toArray() %}
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="{{ url_for(cat.path) }}" itemprop="url" rel="index"><span itemprop="name">{{ cat.name }}</span></a>
</span>
{%- set cat_length = post.categories.length %}
{%- if cat_length > 1 and loop.index !== cat_length %}
{{ __('symbol.comma') }}
{%- endif %}
{%- endfor %}
</span>
{%- endif %}
{# LeanCloud PageView #}
{%- if theme.leancloud_visitors.enable or (theme.valine.enable and theme.valine.appid and theme.valine.appkey and theme.valine.visitor) %}
<span id="{{ url_for(post.path) }}" class="post-meta-item leancloud_visitors" data-flag-title="{{ post.title }}" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="leancloud-visitors-count"></span>
</span>
{%- endif %}
{%- if theme.firestore.enable %}
<span class="post-meta-item" title="{{ __('post.views') }}">
<span class="post-meta-item-icon">
<i class="fa fa-users"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span class="firestore-visitors-count"></span>
</span>
{%- endif %}
{%- if not is_index and theme.busuanzi_count.enable and theme.busuanzi_count.post_views %}
<span class="post-meta-item" title="{{ __('post.views') }}" id="busuanzi_container_page_pv" style="display: none;">
<span class="post-meta-item-icon">
<i class="{{ theme.busuanzi_count.post_views_icon }}"></i>
</span>
<span class="post-meta-item-text">{{ __('post.views') + __('symbol.colon') }}</span>
<span id="busuanzi_value_page_pv"></span>
</span>
{%- endif %}
{{- next_inject('postMeta') }}
{%- if config.symbols_count_time.symbols %}
{%- if theme.symbols_count_time.separated_meta %}<br>{%- endif %}
<span class="post-meta-item" title="{{ __('symbols_count_time.count') }}">
<span class="post-meta-item-icon">
<i class="far fa-file-word"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.count') + __('symbol.colon') }}</span>
{%- endif %}
<span>{{ symbolsCount(post) }}</span>
</span>
{%- endif %}
{%- if config.symbols_count_time.time %}
<span class="post-meta-item" title="{{ __('symbols_count_time.time') }}">
<span class="post-meta-item-icon">
<i class="far fa-clock"></i>
</span>
{%- if theme.symbols_count_time.item_text_post %}
<span class="post-meta-item-text">{{ __('symbols_count_time.time') }} ≈</span>
{%- endif %}
<span>{{ symbolsTime(post, config.symbols_count_time.awl, config.symbols_count_time.wpm, __('symbols_count_time.time_minutes')) }}</span>
</span>
{%- endif %}
{%- if post.description and (not theme.excerpt_description or not is_index) %}
<div class="post-description">{{ post.description }}</div>
{%- endif %}
</div>
</header>
{%- endif %}
{#################}
{### POST BODY ###}
{#################}
<div class="post-body{%- if post.direction and post.direction.toLowerCase() === 'rtl' %} rtl{%- endif %}" itemprop="articleBody">
{# Gallery support #}
{%- if post.photos and post.photos.length %}
<div class="post-gallery" itemscope itemtype="http://schema.org/ImageGallery">
{%- for photo in post.photos %}
<img src="{{ url_for(photo) }}" itemprop="contentUrl">
{%- endfor %}
</div>
{%- endif %}
{%- if is_index %}
{%- if post.description and theme.excerpt_description %}
<p>{{ post.description }}</p>
<!--noindex-->
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}">
{{ __('post.read_more') }} »
</a>
</div>
{%- endif %}
<!--/noindex-->
{% elif post.excerpt %}
{{ post.excerpt }}
<!--noindex-->
{%- if theme.read_more_btn %}
<div class="post-button">
<a class="btn" href="{{ url_for(post.path) }}#more" rel="contents">
{{ __('post.read_more') }} »
</a>
</div>
{%- endif %}
<!--/noindex-->
{% else %}
{{ post.content }}
{%- endif %}
{% else %}
{{ post.content }}
{%- endif %}
</div>
{#####################}
{### END POST BODY ###}
{#####################}
{%- if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %}
{{ partial('_partials/post/post-related.swig') }}
{%- endif %}
{%- if not is_index %}
{{- next_inject('postBodyEnd') }}
{%- if post.reward_settings.enable %}
{{ partial('_partials/post/post-reward.swig') }}
{%- endif %}
{%- if theme.creative_commons.license and theme.creative_commons.post %}
{{ partial('_partials/post/post-copyright.swig') }}
{%- endif %}
{%- if theme.follow_me %}
{{ partial('_partials/post/post-followme.swig', {}, {cache: theme.cache.enable}) }}
{%- endif %}
<footer class="post-footer">
{%- if post.tags and post.tags.length %}
{%- if theme.tag_icon %}
{%- set tag_indicate = '<i class="fa fa-tag"></i>' %}
{% else %}
{%- set tag_indicate = '#' %}
{%- endif %}
<div class="post-tags">
{%- for tag in post.tags.toArray() %}
<a href="{{ url_for(tag.path) }}" rel="tag">{{ tag_indicate }} {{ tag.name }}</a>
{%- endfor %}
</div>
{%- endif %}
{{ partial('_partials/post/post-footer.swig', {}, {cache: theme.cache.enable}) }}
{{ post_nav(post) }}
</footer>
{% else %}
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
{%- endif %}
</article>
{######################}
{### END POST BLOCK ###}
{######################}