In my current theme I am checking for different contexts to decide which information I display in the head portion of the blog:
[...]
<header class="bg-dark d-flex flex-column flex-grow-0 flex-shrink-0 mb-5" style="height: 45vh; min-height: 270px; background: linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url({{background}}); background-position: 50% 50%; background-repeat: no-repeat; background-size: cover;">
{{> "trans-nav" }}
<div class="container d-flex flex-column justify-content-center align-items-center h-100" style="margin-top: -56px;">
{{#is 'index'}}
{{#if @site.logo}}<img src="{{@site.logo}}">{{/if}}
<h1 class="text-white font-weight-bold ">{{@site.title}}</h1>
<p class="lead text-white-50 font-weight-bold">{{@site.description}}</p>
{{/is}}
{{#is 'page'}}
<h1 class="text-white font-weight-bold display-4 text-center text-xl-left">{{title}}</h1>
{{/is}}
{{#is 'post'}}
<h4 class="post-date text-white-50 font-weight-bold" >{{date published_at format="MMMM DD, YYYY"}}</h4>
<h1 class="text-white font-weight-bold display-4 text-center text-xl-left">{{title}}</h1>iv>
{{/is}}
{{#is 'tag'}}
<h1 class="text-white font-weight-bold text-capitalize">{{name}} <span class="badge badge-primary">{{total_posts}}</span></h1>
{{#if description}}<p class="lead text-white-50 font-weight-bold">{{description}}</p>{{/if}}
{{/is}}
</div>
{{else}}
[...]
I am using internal tags like #micro
and #link
to implement a basic version of custom post types. To be able to target only these types of posts, I decided to create custom routes/channels:
routes:
/links/:
controller: channel
filter: tag:link
/micros/:
controller: channel
filter: tag:micro
/posts/:
controller: channel
filter: tag:-[link,micro]
collections:
/:
permalink: /{slug}/
template:
- index
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
But whenever I go to the URL of one of the routes, my header is empty, as it does not fit into any of the contexts. Is there a context I can target for each of the channels/routes? Or do I have to implement some kind of default? Is there an {{#elseis}}
statement for {{#is}}
?