mnts.dev/post.hbs

327 lines
12 KiB
Handlebars
Raw Normal View History

{{!< default}}
2017-06-13 18:07:26 +00:00
2017-05-15 20:03:47 +00:00
{{!-- The tag above means: insert everything in this file
into the {body} of the default.hbs template --}}
<header class="site-header outer">
<div class="inner">
2017-06-13 18:02:22 +00:00
{{> "site-nav"}}
2017-05-15 20:03:47 +00:00
</div>
</header>
{{!-- Everything inside the #post tags pulls data from the post --}}
2014-09-25 14:35:06 +00:00
{{#post}}
2017-05-15 20:03:47 +00:00
<main id="site-main" class="site-main outer" role="main">
<div class="inner">
2017-06-05 11:19:29 +00:00
<article class="post-full {{post_class}} {{#unless feature_image}}no-image{{/unless}}">
2017-05-15 20:03:47 +00:00
<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>
{{#primary_tag}}
<span class="date-divider">/</span> <a href="{{url}}">{{name}}</a>
{{/primary_tag}}
2017-05-15 20:03:47 +00:00
</section>
<h1 class="post-full-title">{{title}}</h1>
</header>
2017-05-15 20:03:47 +00:00
{{#if feature_image}}
<figure class="post-full-image" style="background-image: url({{feature_image}})">
</figure>
{{/if}}
2017-05-15 20:03:47 +00:00
<section class="post-full-content">
{{content}}
</section>
2013-09-01 19:45:19 +00:00
{{!-- Email subscribe form at the bottom of the page --}}
{{#if @labs.subscribers}}
2017-05-15 20:03:47 +00:00
<section class="subscribe-form">
<h3 class="subscribe-form-title">Subscribe to {{@blog.title}}</h3>
<p>Get the latest posts delivered right to your inbox</p>
{{subscribe_form placeholder="youremail@example.com"}}
</section>
{{/if}}
2017-05-15 20:03:47 +00:00
<footer class="post-full-footer">
2018-04-10 18:19:29 +00:00
{{!-- If there are multiple authors for the post, display all of their avatars in a stack --}}
{{#has author="count:>1"}}
<section class="post-full-authors">
<div class="post-full-authors-content">
<p>This post was a collaboration between</p>
<p>{{authors}}</p>
</div>
<ul class="author-list">
{{#foreach authors}}
<li class="author-list-item">
<div class="author-card">
<div class="basic-info">
{{#if profile_image}}
<img class="author-profile-image" src="{{profile_image}}" alt="{{name}}" />
{{else}}
<span class="avatar-wrapper">{{> "icons/avatar"}}</span>
{{/if}}
<h2>{{name}}</h2>
</div>
<div class="bio">
{{#if bio}}
<p>{{bio}}</p>
<p><a href="{{url}}">More posts</a> by {{name}}.</p>
{{else}}
<p>Read <a href="{{url}}">more posts</a> by this author.</p>
{{/if}}
</div>
</div>
{{#if profile_image}}
<a href="{{url}}" class="moving-avatar"><img class="author-profile-image" src="{{profile_image}}" alt="{{name}}" /></a>
{{else}}
<a href="{{url}}" class="moving-avatar"><span class="avatar-wrapper">{{> "icons/avatar"}}</span></a>
{{/if}}
</li>
{{/foreach}}
</ul>
</section>
{{!-- If there is a single author for the post, display her/his information --}}
{{else}}
{{!-- Everything inside the #author tags pulls data from the author --}}
{{#author}}
<section class="author-card">
{{#if profile_image}}
<img class="author-profile-image" src="{{profile_image}}" alt="{{name}}" />
2017-05-15 20:03:47 +00:00
{{else}}
2018-04-10 18:19:29 +00:00
<span class="avatar-wrapper">{{> "icons/avatar"}}</span>
2017-05-15 20:03:47 +00:00
{{/if}}
2018-04-10 18:19:29 +00:00
<section class="author-card-content">
<h4 class="author-card-name"><a href="{{url}}">{{name}}</a></h4>
{{#if bio}}
<p>{{bio}}</p>
{{else}}
<p>Read <a href="{{url}}">more posts</a> by this author.</p>
{{/if}}
</section>
2017-05-15 20:03:47 +00:00
</section>
2018-04-10 18:19:29 +00:00
<div class="post-full-footer-right">
<a class="author-card-button" href="{{url}}">Read More</a>
</div>
{{/author}}
{{/has}}
2017-05-15 20:03:47 +00:00
</footer>
2017-06-08 07:19:22 +00:00
{{!--
2017-06-13 18:07:26 +00:00
If you use Disqus comments, just uncomment this block.
The only thing you need to change is "test-apkdzgmqhj" - which
should be replaced with your own Disqus site-id.
2017-06-05 11:19:29 +00:00
<section class="post-full-comments">
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
2017-06-08 07:19:22 +00:00
this.page.url = '{{url absolute="true"}}';
this.page.identifier = 'ghost-{{comment_id}}';
2017-06-05 11:19:29 +00:00
};
(function() {
2017-06-08 07:19:22 +00:00
var d = document, s = d.createElement('script');
s.src = 'https://test-apkdzgmqhj.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
2017-06-05 11:19:29 +00:00
})();
</script>
</section>
2017-06-08 07:19:22 +00:00
--}}
2017-06-05 11:19:29 +00:00
2017-05-15 20:03:47 +00:00
</article>
</div>
</main>
2014-09-25 14:35:06 +00:00
{{!-- Links to Previous/Next posts --}}
2017-05-15 20:03:47 +00:00
<aside class="read-next outer">
<div class="inner">
<div class="read-next-feed">
{{#if primary_tag}}
{{#get "posts" filter="tags:{{primary_tag.slug}}+id:-{{id}}" limit="3" as |related_posts|}}
{{#if related_posts}}
2017-06-12 09:01:00 +00:00
<article class="read-next-card"
{{#if ../primary_tag.feature_image}}
style="background-image: url({{../primary_tag.feature_image}})"
2017-06-12 09:01:00 +00:00
{{else}}
{{#if @blog.cover_image}}
style="background-image: url({{@blog.cover_image}})"{{/if}}
{{/if}}
>
<header class="read-next-card-header">
2017-06-13 17:51:08 +00:00
<small class="read-next-card-header-sitetitle">&mdash; {{@blog.title}} &mdash;</small>
{{#../primary_tag}}
<h3 class="read-next-card-header-title"><a href="{{url}}">{{name}}</a></h3>
{{/../primary_tag}}
2017-06-12 09:01:00 +00:00
</header>
<div class="read-next-divider">{{> "icons/infinity"}}</div>
<div class="read-next-card-content">
2017-06-13 17:51:08 +00:00
<ul>
{{#foreach related_posts}}
2017-06-12 09:01:00 +00:00
<li><a href="{{url}}">{{title}}</a></li>
{{/foreach}}
2017-06-13 17:51:08 +00:00
</ul>
2017-06-12 09:01:00 +00:00
</div>
2017-06-13 17:51:08 +00:00
<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>
2017-06-13 17:51:08 +00:00
</footer>
2017-06-12 09:01:00 +00:00
</article>
{{/if}}
2017-05-15 20:03:47 +00:00
{{/get}}
{{/if}}
2017-05-15 20:03:47 +00:00
2017-06-12 09:01:00 +00:00
{{!-- If there's a next post, display it using the same markup included from - partials/post-card.hbs --}}
2017-05-15 20:03:47 +00:00
{{#next_post}}
2017-06-12 09:01:00 +00:00
{{> "post-card"}}
2017-05-15 20:03:47 +00:00
{{/next_post}}
2017-06-12 09:01:00 +00:00
{{!-- If there's a previous post, display it using the same markup included from - partials/post-card.hbs --}}
2017-05-15 20:03:47 +00:00
{{#prev_post}}
2017-06-12 09:01:00 +00:00
{{> "post-card"}}
2017-05-15 20:03:47 +00:00
{{/prev_post}}
</div>
</div>
2015-03-27 17:10:31 +00:00
</aside>
2017-06-15 14:03:19 +00:00
{{!-- Floating header which appears on-scroll, included from includes/floating-header.hbs --}}
{{> floating-header}}
2014-09-25 14:35:06 +00:00
{{/post}}
2017-06-08 07:19:22 +00:00
{{!-- The #contentFor helper here will send everything inside it up to the matching #block helper found in default.hbs --}}
{{#contentFor "scripts"}}
<script>
2017-06-18 23:11:32 +00:00
// NOTE: Scroll performance is poor in Safari
// - this appears to be due to the events firing much more slowly in Safari.
// Dropping the scroll event and using only a raf loop results in smoother
// scrolling but continuous processing even when not scrolling
$(document).ready(function () {
// Start fitVids
var $postContent = $(".post-full-content");
$postContent.fitVids();
// End fitVids
var progressBar = document.querySelector('progress');
var header = document.querySelector('.floating-header');
var title = document.querySelector('.post-full-title');
var lastScrollY = window.scrollY;
var lastWindowHeight = window.innerHeight;
var lastDocumentHeight = $(document).height();
var ticking = false;
function onScroll() {
lastScrollY = window.scrollY;
requestTick();
2017-06-14 11:16:16 +00:00
}
2017-06-18 23:11:32 +00:00
function onResize() {
lastWindowHeight = window.innerHeight;
lastDocumentHeight = $(document).height();
requestTick();
2017-06-14 11:16:16 +00:00
}
2017-06-18 23:11:32 +00:00
function requestTick() {
if (!ticking) {
requestAnimationFrame(update);
}
ticking = true;
}
2017-06-14 11:16:16 +00:00
2017-06-18 23:11:32 +00:00
function update() {
var trigger = title.getBoundingClientRect().top + window.scrollY;
var triggerOffset = title.offsetHeight + 35;
var progressMax = lastDocumentHeight - lastWindowHeight;
2017-06-14 11:16:16 +00:00
2017-06-18 23:11:32 +00:00
// show/hide floating header
if (lastScrollY >= trigger + triggerOffset) {
header.classList.add('floating-active');
} else {
header.classList.remove('floating-active');
2017-06-14 11:16:16 +00:00
}
2017-06-18 23:11:32 +00:00
progressBar.setAttribute('max', progressMax);
progressBar.setAttribute('value', lastScrollY);
2017-06-14 11:16:16 +00:00
2017-06-18 23:11:32 +00:00
ticking = false;
2017-06-14 11:16:16 +00:00
}
2017-06-18 23:11:32 +00:00
window.addEventListener('scroll', onScroll, {passive: true});
window.addEventListener('resize', onResize, false);
update();
2018-04-10 18:19:29 +00:00
});
// Adds delay to author card dropups to disappear. This gives enough
// time for the user to interact with the author card while they move
// the mouse from the avatar to the card. Also makes space for the
// interacted avatar.
$(document).ready(function () {
var hoverTimeout;
var direction = 'left';
$('.author-list-item:first-child').addClass('first-child');
function makeSpaceForAvatar(avatar) {
if (avatar.hasClass('first-child')) {
return;
}
$('.author-list-item').each(function(i, obj) {
if ($(this)[0] != avatar[0]) {
if (Number($(this).css('z-index')) > Number(avatar.css('z-index'))) {
$(this).children('.moving-avatar').addClass('left');
} else {
$(this).children('.moving-avatar').addClass('right');
}
}
});
}
$('.author-list-item').hover(function(){
var $this = $(this);
clearTimeout(hoverTimeout);
$('.author-card').removeClass('hovered');
$(this).children('.author-card').addClass('hovered');
makeSpaceForAvatar($this);
}, function() {
var $this = $(this);
$('.author-list-item').children('.moving-avatar').removeClass('left right');
hoverTimeout = setTimeout(function() {
$this.children('.author-card').removeClass('hovered');
}, 800);
});
2017-06-08 07:19:22 +00:00
});
</script>
{{/contentFor}}