re-added scope variable to differentiate between list and single pages

This commit is contained in:
Lars Hoogestraat 2022-02-06 15:49:16 +01:00
parent f0e29bf4c5
commit ee61489da8
5 changed files with 29 additions and 16 deletions

View File

@ -1,4 +1,4 @@
baseURL = 'http://localhost/'
baseURL = 'https://hugodemo.hoogi.eu/'
languageCode = "en-us"
DefaultContentLanguage = "en"
title = 'This is an example site'

View File

@ -1,5 +1,6 @@
{{ define "main" }}
{{ range .Paginator.Pages }}
{{ .Scratch.Set "scope" "list" }}
<article>
<header>
<h1>

View File

@ -1,6 +1,9 @@
<h1>
{{.Title}}
<a href="{{.Permalink}}">{{.Title}}</a>
{{ if eq (.Scratch.Get "scope") "single" }}
{{.Title}}
{{ else }}
<a href="{{.Permalink}}">{{.Title}}</a>
{{ end }}
</h1>
<p>
{{ if .Date }} written {{ if .Params.Author }} by {{ .Params.Author }} {{ end }} on

21
layouts/posts/list.html Normal file
View File

@ -0,0 +1,21 @@
{{ define "main" }}
{{ range .Paginator.Pages }}
{{ .Scratch.Set "scope" "list" }}
<article>
<header>
{{ partial "article-header.html" . }}
</header>
{{ if .Site.Params.useSummary }}
{{ .Summary }}
{{ partial "article-footer.html" . }}
{{ else }}
{{.Content}}
{{ partial "article-footer.html" . }}
{{ end }}
</article>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}

View File

@ -2,19 +2,7 @@
{{ .Scratch.Set "scope" "single" }}
<article>
<header>
<h1>
{{.Title}}
</h1>
<p>
{{ if .Date }} written {{ if .Params.Author }} by {{ .Params.Author }} {{ end }} on
<time>{{ .Date.Format "Jan 2, 2006" }}</time>{{ end }}
{{ if .Params.categories }}
in
{{ range .Params.categories }}
<a href="{{ $.Site.BaseURL }}categories/{{ . | urlize }}">{{ . | humanize }}</a>
{{ end }}
{{ end }}
</p>
{{ partial "article-header.html" . }}
</header>
{{ .Content }}
</article>