Make a better use of Hugo theme
This commit is contained in:
parent
d29e5bbdb3
commit
20c01b8868
11 changed files with 787 additions and 5 deletions
107
layouts/partials/header.html
Normal file
107
layouts/partials/header.html
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
{{- partial "load-photoswipe-theme.html" . }}
|
||||
|
||||
{{ if .IsHome }}
|
||||
{{ if .Site.Params.homeTitle }}{{ $.Scratch.Set "title" .Site.Params.homeTitle }}{{ end }}
|
||||
{{ if .Site.Params.subtitle }}{{ $.Scratch.Set "subtitle" .Site.Params.subtitle }}{{ end }}
|
||||
{{ if .Site.Params.bigimg }}{{ $.Scratch.Set "bigimg" .Site.Params.bigimg }}{{ end }}
|
||||
{{ if .Site.Params.thumb }}{{ $.Scratch.Set "thumb" .Site.Params.thumb }}{{ end }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "title" .Title }}
|
||||
{{ if .Params.subtitle }}{{ $.Scratch.Set "subtitle" .Params.subtitle }}{{ end }}
|
||||
{{ if .Params.bigimg }}{{ $.Scratch.Set "bigimg" .Params.bigimg }}{{ end }}
|
||||
{{ end }}
|
||||
{{ $bigimg := $.Scratch.Get "bigimg" }}
|
||||
{{ $title := $.Scratch.Get "title" }}
|
||||
{{ $subtitle := $.Scratch.Get "subtitle" }}
|
||||
{{ $thumbs := $.Scratch.Get "thumb" }}
|
||||
|
||||
{{ if or (or $bigimg $title) $thumbs }}
|
||||
{{ if $bigimg }}
|
||||
<div id="header-big-imgs" data-num-img={{len $bigimg}}
|
||||
{{range $i, $img := $bigimg}}
|
||||
{{ if (fileExists $img.src)}}
|
||||
data-img-src-{{add $i 1}}="{{$img.src | absURL }}"
|
||||
{{else}}
|
||||
data-img-src-{{add $i 1}}="{{$img.src}}"
|
||||
{{end}}
|
||||
{{ if $img.desc}}data-img-desc-{{add $i 1}}="{{$img.desc}}"{{end}}
|
||||
{{end}}></div>
|
||||
{{ end }}
|
||||
|
||||
<header class="header-section {{ if $bigimg }}has-img{{ end }}">
|
||||
{{ if $bigimg }}
|
||||
<div class="intro-header big-img">
|
||||
{{ $subtitle := $.Scratch.Get "subtitle" }}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="{{ .Type }}-heading">
|
||||
<h1>{{ with $.Scratch.Get "title" }}{{.}}{{ else }}<br/>{{ end }}</h1>
|
||||
{{ if $subtitle }}
|
||||
{{ if eq .Type "page" }}
|
||||
<hr class="small">
|
||||
<span class="{{ .Type }}-subheading">{{ $subtitle }}</span>
|
||||
{{ else }}
|
||||
<h2 class="{{ .Type }}-subheading">{{ $subtitle }}</h2>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if eq .Type "post" }}
|
||||
{{ partial "post_meta.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="img-desc" style="display: inline;"></span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{ if $title }}
|
||||
<div class="intro-header no-img">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
|
||||
<div class="{{ .Type }}-heading">
|
||||
{{ if eq .Type "list" }}
|
||||
<h1>{{ if .Data.Singular }}#{{ end }}{{ .Title }}</h1>
|
||||
{{ else }}
|
||||
<h1>{{ with $title }}{{.}}{{ else }}<br/>{{ end }}</h1>
|
||||
{{ end }}
|
||||
{{ if ne .Type "post" }}
|
||||
<hr class="small">
|
||||
{{ end }}
|
||||
{{ if $subtitle }}
|
||||
{{ if eq .Type "page" }}
|
||||
<span class="{{ .Type }}-subheading">{{ $subtitle }}</span>
|
||||
{{ else }}
|
||||
<h2 class="{{ .Type }}-subheading">{{ $subtitle }}</h2>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if eq .Type "post" }}
|
||||
{{ partial "post_meta.html" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
<div class="intro-header no-img"></div>
|
||||
{{end}}
|
||||
|
||||
{{ if $thumbs }}
|
||||
<div class="container">
|
||||
{{range $i, $thumb := $thumbs}}
|
||||
<a href="{{ $thumb.link | absURL }}" target="_blank">
|
||||
<div class="thumbApp" style="background-image:url('{{ $thumb.src | absURL }}')">
|
||||
{{ if $thumb.desc }}<p><span>{{ $thumb.desc }}</span></p>{{end}}
|
||||
</div>
|
||||
</a>
|
||||
{{ end }}
|
||||
<span style="clear:both; display: block"></span>
|
||||
<hr class="small">
|
||||
</div>
|
||||
{{ end }}
|
||||
</header>
|
||||
{{ else }}
|
||||
<div class="intro-header"></div>
|
||||
{{ end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue