[Journal] Fixed latest post query

fixes #138

When the homepage posts are queried from a custom collection, the latest post didn't use to respect what collection it's in. Now the theme utilizes the main query instead of a custom one for fetching the latest post, so the custom collection works as expected.
This commit is contained in:
Sodbileg Gansukh
2022-10-11 13:31:50 +08:00
parent 039d89a4a0
commit dc7d1ebe8f

View File

@@ -3,32 +3,30 @@
<main id="gh-main" class="gh-main gh-outer">
<div class="gh-inner">
{{^is "paged"}}
{{#get "posts" limit="1"}}
{{#foreach posts}}
<article class="gh-latest gh-card {{post_class}}">
<a class="gh-card-link" href="{{url}}">
<header class="gh-card-header">
<div class="gh-article-meta">
<span class="gh-card-date">Latest — <time datetime="{{date format="YYYY-MM-DD"}}">{{date}}</time></span>
</div>
<h2 class="gh-article-title gh-card-title">{{title}}</h2>
</header>
{{#foreach posts limit="1"}}
<article class="gh-latest gh-card {{post_class}}">
<a class="gh-card-link" href="{{url}}">
<header class="gh-card-header">
<div class="gh-article-meta">
<span class="gh-card-date">Latest — <time datetime="{{date format="YYYY-MM-DD"}}">{{date}}</time></span>
</div>
<h2 class="gh-article-title gh-card-title">{{title}}</h2>
</header>
<p class="gh-article-excerpt">{{excerpt}}</p>
<p class="gh-article-excerpt">{{excerpt}}</p>
<footer class="gh-card-meta">
<span class="gh-card-duration">{{reading_time}}</span>
{{#if @site.comments_enabled}}
{{comment_count class="gh-card-comments"}}
{{/if}}
{{^has visibility="public"}}
{{> icons/star}}
{{/has}}
</footer>
</a>
</article>
{{/foreach}}
{{/get}}
<footer class="gh-card-meta">
<span class="gh-card-duration">{{reading_time}}</span>
{{#if @site.comments_enabled}}
{{comment_count class="gh-card-comments"}}
{{/if}}
{{^has visibility="public"}}
{{> icons/star}}
{{/has}}
</footer>
</a>
</article>
{{/foreach}}
{{/is}}
<div class="gh-wrapper">