make dateFormat configurable

This commit is contained in:
kentnek 2020-06-23 23:20:02 +08:00
parent 9c1b6ac916
commit 1004a391df
5 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,6 @@
@import "colors";
@import "vars";
.post-list__container { .post-list__container {
margin: 0 auto; margin: 0 auto;
max-width: 1200px; max-width: 1200px;

View File

@ -15,6 +15,8 @@ themesDir = "../../"
# Optional params # Optional params
[params] [params]
dateFormat = "Jan 2 2006"
# Links to your social accounts, comment/uncomment as needed. Icons will be displayed for those specified. # Links to your social accounts, comment/uncomment as needed. Icons will be displayed for those specified.
twitter = "https://twitter.com/<your handle>" twitter = "https://twitter.com/<your handle>"
github = "https://github.com/<your handle>" github = "https://github.com/<your handle>"

View File

@ -3,6 +3,8 @@
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}
<div class="post-list__container"> <div class="post-list__container">
<ul class="post-list"> <ul class="post-list">
@ -10,8 +12,7 @@
<li class="post"> <li class="post">
<div class="post__header"> <div class="post__header">
<time class="post__date" datetime="{{ .Date }}" <time class="post__date" datetime="{{ .Date }}"
>{{ .Date.Format "Jan 2 2006" }}</time >{{ .Date.Format $dateFormat }}</time>
>
<h2 class="post__title"> <h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a> <a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2> </h2>

View File

@ -3,11 +3,13 @@
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}
<div class="post"> <div class="post">
<header class="post__header"> <header class="post__header">
<h1 class="post__title">{{.Title}}</h1> <h1 class="post__title">{{.Title}}</h1>
<time datetime="{{ .Date }}" class="post__date" <time datetime="{{ .Date }}" class="post__date"
>{{ .Date.Format "Jan 2 2006" }}</time >{{ .Date.Format $dateFormat }}</time
> >
</header> </header>
<article class="post__content"> <article class="post__content">

View File

@ -3,6 +3,8 @@
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}
<div class="post-list__container"> <div class="post-list__container">
<div class="tag__header"> <div class="tag__header">
<a href="/blog">All posts</a><span class="separator">/</span> <a href="/blog">All posts</a><span class="separator">/</span>
@ -12,7 +14,7 @@
{{ range .Data.Pages }} {{ range .Data.Pages }}
<li class="post"> <li class="post">
<div class="post__header"> <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"> <h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a> <a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2> </h2>