diff options
author | Track3 <pengliabc@live.cn> | 2019-01-02 07:08:30 +0300 |
---|---|---|
committer | Track3 <pengliabc@live.cn> | 2019-01-02 07:08:30 +0300 |
commit | f601584822fb6cc5877b2a28848e6103a775b35f (patch) | |
tree | e9d3d7fd5e168002556a838763f7d85aef8da895 | |
parent | 1e17ccb8012d9ff48ceba737e49ec5e5444247d6 (diff) |
Add featured image to normal page template
-rw-r--r-- | archetypes/default.md | 1 | ||||
-rw-r--r-- | layouts/_default/single.html | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/archetypes/default.md b/archetypes/default.md index d9b98b1..63c1c63 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -3,5 +3,6 @@ title: "{{ replace .Name "-" " " | title }}" date: {{ .Date }} draft: true comments: false +images: --- diff --git a/layouts/_default/single.html b/layouts/_default/single.html index ef53a18..a00bc3b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,8 +1,25 @@ +{{ define "head" }} + <style> + .bg-img {background-image: url(' + {{- if .Params.featuredImg -}} + {{.Params.featuredImg | absURL}} + {{- else if .Params.images -}} + {{- range first 1 .Params.images -}} + {{. | absURL}} + {{- end -}} + {{- end -}} + ');} + </style> +{{ end }} + {{ define "header" }} -{{ partialCached "header.html" . }} +{{ partial "header.html" . }} {{ end }} {{ define "main" }} + {{- if (or .Params.images .Params.featuredImg) }} + <div class="bg-img"></div> + {{- end }} <main class="site-main section-inner thin animated fadeIn faster"> <h1>{{ .Title }}</h1> <div class="content"> |