-
Notifications
You must be signed in to change notification settings - Fork 1
/
post.hbs
170 lines (151 loc) · 6.84 KB
/
post.hbs
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
{{!< default}}
{{!-- The tag above means: insert everything in this file into the body of the default.hbs template --}}
{{#post}}
{{#if primary_tag}}
{{#if primary_tag.accent_color}}
<style>
:root {
--section-color: {{primary_tag.accent_color}};
}
</style>
{{/if}}
{{/if}}
<main class="gh-main">
<article class="gh-article {{post_class}}">
<header class="gh-article-header gh-canvas">
{{#if primary_tag}}
{{#primary_tag}}
<a class="gh-article-section{{#match slug "=" "catnip"}} rainbow-text{{/match}}" href="{{url}}"{{#if accent_color}} style="color: {{accent_color}}"{{/if}}>{{name}}</a>
{{/primary_tag}}
{{/if}}
<h1 class="gh-article-title is-title">{{title}}</h1>
{{#if custom_excerpt}}
<p class="gh-article-excerpt is-body">{{custom_excerpt}}</p>
{{/if}}
{{#if @custom.show_post_metadata}}
<div class="gh-article-meta">
<div class="gh-article-author-image instapaper_ignore">
{{#foreach authors}}
{{#if profile_image}}
<a href="/author/{{slug}}/">
<img class="author-profile-image" src="{{img_url profile_image size="xs"}}" alt="{{name}}">
</a>
{{else}}
<a href="/author/{{slug}}/">{{> "icons/avatar"}}</a>
{{/if}}
{{/foreach}}
</div>
<div class="gh-article-meta-wrapper">
<h4 class="gh-article-author-name">{{#foreach authors}}{{#unless @first}}, {{/unless}}<a href="/author/{{slug}}/">{{name}}</a>{{/foreach}}</h4>
<div class="gh-article-meta-content">
<time class="gh-article-meta-date" datetime="{{date format="YYYY-MM-DD"}}">{{date}}</time>
{{#if reading_time}}
<span class="gh-article-meta-length"><span class="bull">—</span> {{reading_time}}</span>
{{/if}}
</div>
</div>
</div>
{{/if}}
</header>
<section class="gh-content gh-canvas is-body{{#if @custom.enable_drop_caps_on_posts}} drop-cap{{/if}}">
{{#has tag="#Show feature image,#import-hugo,#import-xelif"}}
{{> "feature-image"}}
{{/has}}
{{content}}
</section>
{{^has tag="#Show feature image,#import-hugo,#import-xelif"}}
{{#if feature_image_caption}}
<footer class="gh-article-footer gh-canvas">
<p>Feature image: {{feature_image_caption}}</p>
</footer>
{{/if}}
{{/has}}
</article>
<!-- Iterate over each tag, check if the tag has a slug starting with "issue-", output its details -->
{{#foreach tags}}
{{#get "tags" filter="slug:~^'issue-'+slug:{{slug}}" limit="1" as |issue|}}
{{#issue}}
<div class="gh-canvas">
<div class="gh-issue{{#unless feature_image}} no-front-cover{{/unless}}">
{{> "feature-image"}}
<div class="gh-issue-description">
<h3>From <span class="gh-issue-name">{{name}}</span></h3>
<!-- Since the date the tag was created is unreliable, instead get the oldest post with this tag. -->
{{#get "posts" filter="tag:{{slug}}" order="published_at asc" limit="1" as |oldest_post|}}
{{#oldest_post}}
<em><time datetime="{{date format="YYYY-MM-DD"}}">{{date format="Do MMMM YYYY"}}</time></em>
{{/oldest_post}}
{{/get}}
<p>Discover stories from this section and more in the list of contents</p>
<a class="link-with-arrow-icon" href="{{url}}">{{> "icons/arrow"}}<span>Explore the edition</span></a>
</div>
</div>
</div>
{{/issue}}
{{/get}}
{{/foreach}}
{{#if @custom.show_edit_article_link}}
<div class="gh-comments gh-canvas">
<a href="/ghost/#/editor/post/{{id}}/">Edit this article</a>
</div>
{{/if}}
{{#if comments}}
<div class="gh-comments gh-canvas">
{{comments}}
</div>
{{/if}}
</main>
{{/post}}
{{#if @custom.show_related_articles}}
<!--
A simple related article recommendation engine.
Related articles are those in the same issue or those written in the same section at a similar time.
Pointing one set of recommendations forwards in time,
and the other backwards ensures good inter-linking between articles to keep readers interested.
-->
{{#get "posts" include="authors,tags"
filter="id:-{{post.id}}+tag:[{{post.tags.[1].slug}}]+created_at:<'{{post.created_at}}'"
limit="4" as |next|}}
{{#if next}}
<!--
Articles in the same issue point backwards,
i.e. only show articles created before them in the same issue.
-->
{{#match next.length ">" "2"}}
<section class="gh-container is-grid gh-outer">
<div class="gh-container-inner gh-inner">
<h2 class="gh-container-title">More from this issue</h2>
<div class="gh-feed">
{{#foreach next}}
{{> "post-card" lazyLoad=true}}
{{/foreach}}
</div>
</div>
</section>
{{/match}}
{{/if}}
{{/get}}
{{#get "posts" include="authors"
filter="id:-{{post.id}}+tag:[{{post.primary_tag.slug}}]+tag:-[{{post.tags.[1].slug}}]+created_at:>'{{post.created_at}}'"
limit="4" as |next|}}
{{#if next}}
<!--
Recommendations in the same section exclude those in the same article
because recommending the same article twice looks bad.
These recommendations look forwards in time.
-->
{{#match next.length ">" "2"}}
<section class="gh-container is-grid gh-outer">
<div class="gh-container-inner gh-inner">
<h2 class="gh-container-title">More from this section</h2>
<div class="gh-feed">
{{#foreach next}}
{{> "post-card" lazyLoad=true}}
{{/foreach}}
</div>
</div>
</section>
{{/match}}
{{/if}}
{{/get}}
{{/if}}