-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.hbs
189 lines (164 loc) · 7.01 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
177
178
179
180
181
182
183
184
185
186
187
188
189
{{!< default}}
{{#post}}
<article class="gh-article {{post_class}}">
<header class="gh-header gh-canvas">
<div class="post-header mx-auto">
<h1 class="gh-title text-size-lg/display uppercase mt-16">{{title}}</h1>
{{#if custom_excerpt}}
<p class="gh-excerpt mx-auto">{{custom_excerpt}}</p>
{{/if}}
<div class="gh-feature-image-wrapper my-32">
{{#if feature_image}}
<figure class="gh-feature-image mt-8 lg:px-48">
<picture>
<source
srcset="
{{img_url feature_image size="xxs" format="avif"}} 30w,
{{img_url feature_image size="xs" format="avif"}} 100w,
{{img_url feature_image size="s" format="avif"}} 300w,
{{img_url feature_image size="m" format="avif"}} 600w,
{{img_url feature_image size="l" format="avif"}} 1200w,
{{img_url feature_image size="xl" format="avif"}} 2000w"
sizes="(min-width: 1200px) 1200px, 90vw"
type="image/avif"
>
<source
srcset="
{{img_url feature_image size="xxs" format="webp"}} 30w,
{{img_url feature_image size="xs" format="webp"}} 100w,
{{img_url feature_image size="s" format="webp"}} 300w,
{{img_url feature_image size="m" format="webp"}} 600w,
{{img_url feature_image size="l" format="webp"}} 1200w,
{{img_url feature_image size="xl" format="webp"}} 2000w"
sizes="(min-width: 1200px) 1200px, 90vw"
type="image/webp"
>
<img
srcset="
{{img_url feature_image size="xxs"}} 30w,
{{img_url feature_image size="xs"}} 100w,
{{img_url feature_image size="s"}} 300w,
{{img_url feature_image size="m"}} 600w,
{{img_url feature_image size="l"}} 1200w,
{{img_url feature_image size="xl"}} 2000w"
sizes="(min-width: 1200px) 1200px, 90vw"
src="{{img_url feature_image size="l"}}"
alt="{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{title}}{{/if}}"
>
</picture>
{{#if feature_image_caption}}
<figcaption>{{feature_image_caption}}</figcaption>
{{/if}}
</figure>
{{/if}}
</div>
</div>
<div class="my-24 py-16 border-black border-t border-b">
<div class="flex justify-between max-w-5xl mx-auto">
<span class="gh-post-meta"><time datetime="{{date format="MMMM D, YYYY"}}">{{date format="MMMM D, YYYY"}}</time> <span class="bull">•</span> {{reading_time}}</span>
{{> "share-button"}}
</div>
</div>
<div class="inline-grid grid-cols-1 items-start w-auto">
<div class="gh-post-authors text-size-1 uppercase mb-3">
By {{#foreach authors}}<a href="{{url}}">{{name}}</a>{{/foreach}}
</div>
<div class="gradient-line-horizontal"></div>
</div>
</header>
<div class="gh-content gh-canvas">
{{content}}
</div>
<footer class="gh-footer gh-canvas">
{{#if comments}}
<section class="gh-post-comments">
{{comments}}
</section>
{{/if}}
</footer>
</article>
<aside class="gh-readmore">
<div class="gh-readmore-inner gh-container">
<div class="gh-readmore-next">
{{#next_post}}<a href="{{url}}">{{> "icons/arrow-left"}} <h4>{{title}}</h4></a>{{/next_post}}
</div>
<div class="gh-readmore-prev">
{{#prev_post}}<a href="{{url}}">
<h4>{{title}}</h4> {{> "icons/arrow-right"}}
</a>{{/prev_post}}
</div>
</div>
</aside>
<script>
document.addEventListener('DOMContentLoaded', () => {
const tags = [...document.querySelectorAll('.post-tags li')];
const gifTag = tags.find(tag => tag.textContent.startsWith('gif-url:'));
if (gifTag) {
const gifUrl = gifTag.textContent.replace('gif-url:', '').trim();
const gifImage = document.createElement('img');
gifImage.src = gifUrl;
gifImage.alt = 'Post GIF';
gifImage.className = 'gh-feature-image';
const featureImageWrapper = document.querySelector('.gh-feature-image-wrapper');
featureImageWrapper.innerHTML = ''; // Clear existing content
featureImageWrapper.appendChild(gifImage);
}
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const shareModal = document.getElementById("shareModal");
const shareButton = document.querySelector(".share-button");
const closeButton = shareModal ? shareModal.querySelector(".close-button") : null;
const copyButton = shareModal ? shareModal.querySelector(".field button") : null;
const copyInput = shareModal ? shareModal.querySelector(".field input") : null;
const field = shareModal ? shareModal.querySelector(".field") : null;
// Open the share modal
function openShareModal() {
if (shareModal) {
shareModal.classList.remove("hidden");
}
}
// Close the share modal
function closeShareModal() {
if (shareModal) {
shareModal.classList.add("hidden");
}
}
// Event listener for opening the modal
if (shareButton) {
shareButton.addEventListener("click", openShareModal);
}
// Event listener for closing the modal
if (closeButton) {
closeButton.addEventListener("click", closeShareModal);
}
// Close the modal when clicking outside of it
window.addEventListener("click", function(event) {
if (event.target === shareModal) {
closeShareModal();
}
});
// Copy functionality
if (copyButton && copyInput) {
copyButton.addEventListener("click", () => {
copyInput.select();
if (document.execCommand("copy")) {
field.classList.add("active");
copyButton.innerText = "Copied";
setTimeout(() => {
window.getSelection().removeAllRanges();
field.classList.remove("active");
copyButton.innerText = "Copy";
}, 3000);
}
});
}
});
</script>
<ul class="post-tags" style="display: none;">
{{#foreach tags}}
<li>{{name}}</li>
{{/foreach}}
</ul>
{{/post}}