Add featured image to normal page template

This commit is contained in:
Track3 2019-01-02 12:08:30 +08:00
parent 1e17ccb801
commit f601584822
2 changed files with 19 additions and 1 deletions

View File

@ -3,5 +3,6 @@ title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
comments: false
images:
---

View File

@ -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">