forestryio / hugo-theme-novela

Novela, the simplest way to start publishing with Hugo and Forestry.
https://hugo-novela-forestry.netlify.app/
MIT License
360 stars 192 forks source link

Can't display single post in hero #65

Closed thedivtagguy closed 3 years ago

thedivtagguy commented 3 years ago

I'm trying to have a single post displayed on this half of the hero:

image

I've figured out how to divide the hero into two halves with flexbox , but I can't seem to be able to get the code for displaying the single, latest post right. Here is what I have:

{{ $articles := slice }}
{{ with first 1 (where site.RegularPages "Type" "post")}}
  {{ $articles = . }}
{{ end }}
{{ return $articles }}

But this just removes the hero entirely and puts Pages (1) in its place.

image

How do I just display a single post on that half of the hero?

thedivtagguy commented 3 years ago

Fixed. I was not using the . correctly. Here is the code that now renders only the latest post:

{{ range first 1 (where site.RegularPages "Type" "post") }}
 <div class="article-data-outer">
                <div class="image-container">
                  <img src="{{ .Params.hero }}" class="article-image" />
                </div>
                <div class="article-data">
                 <a href="{{ .RelPermalink }}"> <h2 class="article-title">
                    {{ .Title }}
                  </h2>
                  </a>
                  <p class ="hero-excerpt">
                    {{ .Params.excerpt }}
                  </p>
                  <div class="article-metadata">
                    {{ .Date.Format "January 2, 2006" }} • {{ .ReadingTime }} min read
                  </div>
                </div>
              </div>
{{ end }}
    </h1></div>