Skip to content

Commit

Permalink
Merge pull request #43 from kentnek/kent-date-format
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewies committed Jun 23, 2020
2 parents 9c1b6ac + a29b792 commit 7eb26ab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions assets/scss/partials/_post-list.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import "colors";
@import "vars";

.post-list__container {
margin: 0 auto;
max-width: 1200px;
Expand Down
4 changes: 4 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ themesDir = "../../"

# Optional params
[params]
# Follow the Hugo date/time format reference here:
# https://gohugo.io/functions/format/#gos-layout-string
dateFormat = "Jan 2 2006"

# Links to your social accounts, comment/uncomment as needed. Icons will be displayed for those specified.
twitter = "https://twitter.com/<your handle>"
github = "https://github.com/<your handle>"
Expand Down
5 changes: 3 additions & 2 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
{{ end }}

{{ define "main" }}

{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post-list__container">
<ul class="post-list">
{{ range .Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}"
>{{ .Date.Format "Jan 2 2006" }}</time
>
>{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
Expand Down
4 changes: 3 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
{{ end }}

{{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post">
<header class="post__header">
<h1 class="post__title">{{.Title}}</h1>
<time datetime="{{ .Date }}" class="post__date"
>{{ .Date.Format "Jan 2 2006" }}</time
>{{ .Date.Format $dateFormat }}</time
>
</header>
<article class="post__content">
Expand Down
4 changes: 3 additions & 1 deletion layouts/taxonomy/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{{ end }}

{{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post-list__container">
<div class="tag__header">
<a href="/blog">All posts</a><span class="separator">/</span>
Expand All @@ -12,7 +14,7 @@ <h1 class="tag__term">{{ .Title }}</h1>
{{ range .Data.Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}">{{ .Date.Format "Jan 2 2006" }}</time>
<time class="post__date" datetime="{{ .Date }}">{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
Expand Down

0 comments on commit 7eb26ab

Please sign in to comment.