tune theme to re-use more code ; setup fundamentals for content on branch folders
This commit is contained in:
parent
48d3b0789c
commit
1938167450
|
@ -1,14 +1,18 @@
|
|||
{{ partial "header.html" . }}
|
||||
|
||||
{{ if not .Params.isBranchWithContent }}
|
||||
{{if not .IsHome }}
|
||||
<h1>{{ .Title | markdownify }}</h1>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ partial "page_meta.html" .}}
|
||||
{{ end }}
|
||||
|
||||
{{ .Content }}
|
||||
|
||||
{{ if not .Params.isBranchWithContent }}
|
||||
{{ if not .IsHome }}
|
||||
<ul>
|
||||
|
||||
{{ $pages := .Pages }}
|
||||
{{ $paginator := .Paginate (where $pages "Section" "!=" "") }}
|
||||
{{ if (eq .Type "posts") }}
|
||||
|
@ -28,5 +32,6 @@
|
|||
</ul>
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
|
|
|
@ -1,48 +1,9 @@
|
|||
{{ partial "header.html" . }}
|
||||
<div class="article-meta">
|
||||
<h1><span class="title">{{ .Title | markdownify }}</span></h1>
|
||||
{{ with .Params.author }}
|
||||
<h3 class="author">By:
|
||||
{{ if (reflect.IsSlice .) }}
|
||||
{{ delimit . ", " }}
|
||||
{{ else }}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
</h3>
|
||||
{{ end }}
|
||||
|
||||
{{ if (gt .Date 0) }}<h4 class="date">Published: {{ .Date.Format "2006/01/02" }}</h4>{{ end }}
|
||||
{{ if (gt .Lastmod 0) }}<h4 class="date">Last Modified: {{ .Lastmod.Format "2006/01/02" }}</h4>{{ end }}
|
||||
<p class="terms">
|
||||
{{ range $i := (slice "categories" "tags") }}
|
||||
{{ with ($.Param $i) }}
|
||||
{{ $i | title }}: {{ range $k := . }}<a href="{{ relURL (print "/" $i "/" $k | urlize) }}">{{$k}}</a> {{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{ if .Params.toc }}
|
||||
{{ .TableOfContents }}
|
||||
{{ end }}
|
||||
{{ partial "page_meta.html" .}}
|
||||
|
||||
<main>
|
||||
{{ .Content }}
|
||||
</main>
|
||||
|
||||
{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
|
||||
{{ $.Scratch.Set "has_related" true }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $.Scratch.Get "has_related" }}
|
||||
<h2>See Also</h2>
|
||||
<ul>
|
||||
{{ $num_to_show := .Site.Params.related_content_limit | default 15 }}
|
||||
{{ range first $num_to_show (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
|
||||
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
<a class="back_to_top" href="#top">Back to top</a>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
|
|
29
themes/hugo-xmin/layouts/partials/page_meta.html
Normal file
29
themes/hugo-xmin/layouts/partials/page_meta.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<div class="article-meta">
|
||||
<h1><span class="title">{{ .Title | markdownify }}</span></h1>
|
||||
{{ with .Params.author }}
|
||||
<h3 class="author">By:
|
||||
{{ if (reflect.IsSlice .) }}
|
||||
{{ delimit . ", " }}
|
||||
{{ else }}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
</h3>
|
||||
{{ end }}
|
||||
|
||||
{{ if (gt .Date 0) }}<h4 class="date">Published: {{ .Date.Format "2006/01/02" }}</h4>{{ end }}
|
||||
{{ if (gt .Lastmod 0) }}<h4 class="date">Last Modified: {{ .Lastmod.Format "2006/01/02" }}</h4>{{ end }}
|
||||
<p class="terms">
|
||||
{{ range $i := (slice "categories" "tags") }}
|
||||
{{ with ($.Param $i) }}
|
||||
{{ $i | title }}: {{ range $k := . }}<a href="{{ relURL (print "/" $i "/" $k | urlize) }}">{{$k}}</a> {{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</p>
|
||||
<p class="terms">
|
||||
{{ partial "related.html" . }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{ if .Params.toc }}
|
||||
{{ .TableOfContents }}
|
||||
{{ end }}
|
11
themes/hugo-xmin/layouts/partials/related.html
Normal file
11
themes/hugo-xmin/layouts/partials/related.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{{ range first 1 (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
|
||||
{{ $.Scratch.Set "has_related" true }}
|
||||
{{ end }}
|
||||
|
||||
{{ if $.Scratch.Get "has_related" }}
|
||||
Related Pages:
|
||||
{{ $num_to_show := .Site.Params.related_content_limit | default 5 }}
|
||||
{{ range first $num_to_show (where (where .Site.Pages ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" .Permalink) }}
|
||||
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Reference in a new issue