forked from freeCodeCamp/news-theme-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.hbs
176 lines (148 loc) · 6.86 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
171
172
173
174
175
176
{{!< default}}
{{!-- The tag above means: insert everything in this file
into the {body} of the default.hbs template --}}
{{!-- Everything inside the #post tags pulls data from the post --}}
{{#post}}
<main id="site-main" class="site-main outer">
<div class="inner">
<article class="post-full {{post_class}} {{#unless feature_image}}no-image{{/unless}}">
<header class="post-full-header">
<section class="post-full-meta">
<time class="post-full-meta-date"
datetime="{{date format="YYYY-MM-DD"}}">{{date format="D MMMM YYYY"}}</time>
{{#if tags}}
<span class="date-divider">/</span>
{{#foreach tags limit="3"}}
<a href="{{url}}">
#{{name}}
</a>
{{/foreach}}
{{/if}}
</section>
<h1 class="post-full-title">{{title}}</h1>
</header>
<div class="post-full-author-header">
{{!-- There are two options for how we display the byline/author-info.
If the post has more than one author, we load a specific template
from includes/byline-multiple.hbs, otherwise, we just use the
default byline. --}}
{{#has author="freeCodeCamp.org"}}
{{else}}
{{> "byline-single"}}
{{/has}}
</div>
{{> "social-row"}}
{{#if feature_image}}
<figure class="post-full-image">
{{!-- This is a responsive image, it loads different sizes depending on device
https://medium.freecodecamp.org/a-guide-to-responsive-images-with-ready-to-use-templates-c400bd65c433 --}}
<img srcset="{{img_url feature_image size="s"}} 300w,
{{img_url feature_image size="m"}} 600w,
{{img_url feature_image size="l"}} 1000w,
{{img_url feature_image size="xl"}} 2000w" sizes="(max-width: 800px) 400px,
(max-width: 1170px) 700px,
1400px" src="{{img_url feature_image size="xl"}}" alt="{{title}}" />
</figure>
{{/if}}
<section class="post-full-content">
{{#has author="freeCodeCamp.org"}}
<div class="post-content medium-migrated-article">
{{content}}
</div>
{{else}}
<div class="post-content">
{{content}}
</div>
{{/has}}
</section>
{{!-- Email subscribe form at the bottom of the page --}}
{{#if @labs.subscribers}}
<section class="subscribe-form">
<h3 class="subscribe-form-title">Subscribe to {{@site.title}}</h3>
<p>Get the latest posts delivered right to your inbox</p>
{{subscribe_form placeholder="[email protected]"}}
</section>
{{/if}}
{{> "social-row"}}
{{!--
<section class="post-full-comments">
If you want to embed comments, this is a good place to do it!
</section> --}}
<script type="text/javascript">
function loadDiscourseComments() {
document.getElementById('discourse-comments').innerHTML = '';
DiscourseEmbed = {
discourseUrl: 'https://www.freecodecamp.org/forum/',
discourseEmbedUrl: '{{url absolute="true"}}'
};
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
}
if (window && window.addEventListener) {
window.addEventListener('load', function () {
document.getElementById('trigger-load-comments').onclick = loadDiscourseComments;
});
}
</script>
<div id='discourse-comments'>
<button id='trigger-load-comments'>Show comments</button>
</div>
</article>
</div>
</main>
{{!-- Links to Previous/Next posts --}}
<aside class="read-next outer">
<div class="inner">
<div class="read-next-feed">
{{#if primary_tag}}
{{#get "posts" filter="tags:{{primary_tag.slug}}+id:-{{comment_id}}" limit="3" as |related_posts|}}
{{#if related_posts}}
<article class="read-next-card" {{#if ../primary_tag.feature_image}}
style="background-image: url({{img_url ../primary_tag.feature_image size="m"}})" {{else}}
{{#if @site.cover_image}} style="background-image: url({{img_url @site.cover_image size="m"}})" {{/if}}
{{/if}}>
<header class="read-next-card-header">
<p class="read-next-card-header-sitetitle">Countinue reading about</p>
{{#../primary_tag}}
<h3 class="read-next-card-header-title"><a href="{{url}}">{{name}}</a></h3>
{{/../primary_tag}}
</header>
<div class="read-next-card-content">
<ul>
{{#foreach related_posts}}
<li><a href="{{url}}">{{title}}</a></li>
{{/foreach}}
</ul>
</div>
<footer class="read-next-card-footer">
<a href="{{#../primary_tag}}{{url}}{{/../primary_tag}}">{{plural meta.pagination.total empty='No posts' singular='% post' plural='See all % posts'}}
→</a>
</footer>
</article>
{{/if}}
{{/get}}
{{/if}}
{{!-- If there's a next post, display it using the same markup included from - partials/post-card.hbs --}}
{{#next_post}}
{{> "post-card"}}
{{/next_post}}
{{!-- If there's a previous post, display it using the same markup included from - partials/post-card.hbs --}}
{{#prev_post}}
{{> "post-card"}}
{{/prev_post}}
</div>
</div>
</aside>
{{/post}}
{{!-- The #contentFor helper here will send everything inside it up to the matching #block helper found in default.hbs --}}
{{#contentFor "scripts"}}
<script>
$(document).ready(function () {
// Start fitVids
var $postContent = $(".post-full-content");
$postContent.fitVids();
// End fitVids
});
</script>
{{/contentFor}}