Skip to content

Commit

Permalink
fix: make specifying date optional (#83)
Browse files Browse the repository at this point in the history
* fix: make specifying date optional. This is useful for standalone pages like about page.

* chore: remove date from about.md
  • Loading branch information
hugo-sid authored Jul 12, 2023
1 parent 2bddcb2 commit 864f523
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion exampleSite/content/pages/about.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: About
description: 'Hugo, the world''s fastest framework for building websites'
date: '2019-02-28'
author: Hugo Authors
---

Expand Down
6 changes: 4 additions & 2 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<article>
<header class="header">
<h1 class="header-title">{{ .Title }}</h1>
{{ $ISO_time := dateFormat "2006-01-02T15:04:05-07:00" .Date }}
{{ with .Date }}
{{ $ISO_time := dateFormat "2006-01-02T15:04:05-07:00" . }}
<div class="post-meta">
<time datetime="{{ $ISO_time }}" itemprop="datePublished"> {{ .Date | time.Format ":date_medium" }} </time>
<time datetime="{{ $ISO_time }}" itemprop="datePublished"> {{ . | time.Format ":date_medium" }} </time>
</div>
{{ end }}
</header>
{{- if or .Params.toc .Site.Params.toc }}
<details class="toc">
Expand Down

0 comments on commit 864f523

Please sign in to comment.