Skip to content

Commit

Permalink
Special treatment for Tags and Archive pages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmg committed Aug 2, 2020
1 parent c719958 commit 76608e6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions input/_header.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
backgroundImage = $"background-image: url(\"{Context.GetLink(Document.GetString(WebKeys.Image))}\")";
}
string description = Document.WithoutSettings().GetString("Lead") ?? Document.WithoutSettings().GetString(WebKeys.Description);
bool isPost = Document.GetBool("IsPost");
string headerTitle = isPost ? Document.GetString("Title") : Document.GetString("SiteTitle");
string title = Document.GetString("Title") ?? Document.GetString("SiteTitle");
bool isPost = Document.GetBool("IsPost") && title != "Tags" && title != "Archive";
}
<header class="masthead" style="@backgroundImage">
<div class="overlay"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="@(@isPost ? "post-heading" : "site-heading")">
<div class="@(isPost ? "post-heading" : "site-heading")">
<h1>
@headerTitle
@title
@if (Document.GetInt(Keys.Index) > 1)
{
<small>(Page @Document.GetString(Keys.Index))</small>
Expand All @@ -25,7 +25,7 @@
{
<h2 class="subheading">@description</h2>
}
@if (@isPost)
@if (isPost)
{
// This is a blog post so show extra data
<div class="meta">Published on @Document.GetDateTime(WebKeys.Published).ToLongDateString()</div>
Expand Down

2 comments on commit 76608e6

@jaider
Copy link

@jaider jaider commented on 76608e6 Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daveaglick L9 - I think this is wrong. this means that cannot show a post info if the title is "Tags" or "Archive"?

@daveaglick
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaider Nice spot. So I think the issue here is that IsPost tends to get "promoted" through to tag and archive pages and we generally don't want to show the post header for those pages since they're actually site-level pages. I do agree that this is not ideal - while I don't know how many posts would end up with exact titles of "Tags" or "Archive", relying on the title at all seems brittle.

I guess the better approach would be to ensure IsPost gets set to false for those types of pages so that we don't need this check. I created statiqdev/Statiq.Web#995 to track this work.

Please sign in to comment.