matt-dray / rostrum-blog

:memo::bug: Blog: superseded source code for rostrum.blog
Other
6 stars 3 forks source link

Get author name on every post #14

Closed matt-dray closed 5 years ago

matt-dray commented 5 years ago

Must be able to add the author YAML metadata to the post automatically. The date gets there; why not author?

matt-dray commented 5 years ago

To hardcode the author name for all posts (and bring the reading time onto the same line), change themes/hugo-lithium-theme/layouts/_default/single.html to something like this:

{{ partial "header.html" . }}

<main class="content" role="main">

    <h1 class="article-title">{{ .Title }}</h1>

    {{ if eq .Section "post" }}
    <span class="article-date">Matt Dray / {{ .Date.Format "02 Jan 2006" }} / {{ .ReadingTime }} min read</span>
    {{ end }}

    <div class="article-content">
      {{ .Content }}
    </div>
  </article>

  {{ partial "disqus.html" .}}

</main>

{{ partial "footer.html" . }}
matt-dray commented 5 years ago

Could also be nice to then do .article-date { color: #1e8016; } in the CSS at themes/hugo-lithium-theme/static/css/main.css. Results in this:

Screen Shot 2019-05-23 at 00 11 40
matt-dray commented 5 years ago

Aha: {{ .Params.author }} is what I was after.

Cmd+F 'author' here: https://bookdown.org/yihui/blogdown/templates.html#fnref28