Add pagination for news posts
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2022-07-08 04:16:32 +02:00
parent edc4a0a363
commit f26420864f
10 changed files with 92 additions and 20 deletions

View File

@ -1,6 +1,10 @@
--- {{ $name := strings.TrimPrefix (now.Format "2006-01-02-") .Name }}---
title: "{{ replace .Name "-" " " | title }}" slug: "{{ $name }}"
title: "{{ humanize $name }}"
date: {{ .Date }} date: {{ .Date }}
menu:
main:
parent: Aktuelles
draft: true draft: true
--- ---

7
archetypes/pages.md Normal file
View File

@ -0,0 +1,7 @@
---
title: "{{ humanize .Name }}"
menu:
main:
weight: 42
---

View File

@ -1,3 +1,4 @@
$color-burger: #aaa; $color-burger: #aaa;
$color-highlight: #0080ff; $color-highlight: #0080ff;
$color-link: #f0f;
$color-text: #000; $color-text: #000;

View File

@ -76,7 +76,15 @@ nav {
} }
} }
a { &.pagination {
margin-top: 2.5em;
:first-child {
margin: 0;
}
}
a, span {
line-height: 1.5em; line-height: 1.5em;
margin: 0.5em 0 0 0; margin: 0.5em 0 0 0;
} }
@ -89,27 +97,19 @@ nav {
max-height: max-content; max-height: max-content;
} }
a { a, span {
margin: 0 0 0 1em; margin: 0 0 0 1em;
} }
} }
} }
a { a {
color: currentColor; color: $color-link;
text-decoration: none; text-decoration: none;
&:hover { &:hover, &.is-active {
text-decoration: underline; text-decoration: underline;
} }
&.is-active {
color: $color-highlight;
&:hover {
text-decoration: none;
}
}
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
@ -120,6 +120,16 @@ p {
margin-bottom: 1em; margin-bottom: 1em;
} }
ol, ul {
margin-bottom: 2em;
padding-left: 2em;
}
hr {
color: $color-text;
margin: 3em 0;
}
.nav-burger { .nav-burger {
cursor: pointer; cursor: pointer;
display: flex; display: flex;

View File

@ -1,8 +1,13 @@
baseURL = 'https://iger.events/' baseURL = 'https://iger.events/'
languageCode = 'de-de' languageCode = 'de-de'
paginate = 3
title = 'Intergalaktische Erfahrungsreise' title = 'Intergalaktische Erfahrungsreise'
[menu] [menu]
[[menu.footer]]
name = "Kontakt"
url = "mailto:info@fairydust.reisen"
weight = 5
[[menu.footer]] [[menu.footer]]
name = "Impressum" name = "Impressum"
url = "https://hackerspace-bamberg.de/Impressum" url = "https://hackerspace-bamberg.de/Impressum"
@ -13,3 +18,7 @@ title = 'Intergalaktische Erfahrungsreise'
weight = 20 weight = 20
[taxonomies] [taxonomies]
[permalinks]
"/" = "/:year/:month/:slug/"
pages = "/:slug/"

View File

@ -11,10 +11,10 @@
</head> </head>
<body> <body>
<header> <header>
<pre>TEST <pre>INTER
LOGO GALAKTISCHE
PLS ERFAHRUNGS
IGNR</pre> REISE</pre>
<input class="nav-toggle" id="toggleMainNav" type="checkbox"> <input class="nav-toggle" id="toggleMainNav" type="checkbox">
<label class="nav-burger" for="toggleMainNav"> <label class="nav-burger" for="toggleMainNav">
<div></div> <div></div>

View File

@ -1,6 +1,9 @@
{{ define "main" }} {{ define "main" }}
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{ .Content }} {{ .Content }}
<ul>
<!-- TODO: refer to pages in section --> {{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }} {{ end }}

View File

@ -1,3 +1,19 @@
{{ define "main" }} {{ define "main" }}
{{ .Content }} {{ .Content }}
{{ $pagination := .Paginate .RegularPages }}
{{ with .Content }}{{ with $pagination.Pages }}<hr>{{ end }}{{ end }}
{{ range $pagination.Pages }}
<h1><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
{{ .Content }}
{{ if ne .Slug (index (last 1 $pagination.Pages) 0).Slug }}<hr>{{ end }}
{{ end }}
{{ with $pagination }}
{{ if gt .TotalPages 1 }}
<nav class="pagination">
{{ if .HasPrev }}<a href="{{ .Prev.URL }}">&lt; Neuere Posts</a>{{ end }}
<span>{{ .PageNumber }}/{{ .TotalPages }}</span>
{{ if .HasNext }}<a href="{{ .Next.URL }}">Ältere Posts &gt;</a>{{ end }}
</nav>
{{ end }}
{{ end }}
{{ end }} {{ end }}

11
new-page.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
if [ -z "$1" ]
then
echo "usage: $0 <name>" >&2
exit 1
fi
hugo new "content/pages/${1//[^[:alnum:]-_]}.md"

11
new-post.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
if [ -z "$1" ]
then
echo "usage: $0 <name>" >&2
exit 1
fi
hugo new "content/$(date '+%Y-%m-%d')-${1//[^[:alnum:]-_]}.md"