mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-05-09 05:32:58 -05:00
Compare commits
2 Commits
ad7432155f
...
6e7160efbb
Author | SHA1 | Date | |
---|---|---|---|
6e7160efbb | |||
04c3c007a8 |
@ -1,68 +0,0 @@
|
||||
baseURL: https://example.com
|
||||
theme: bobatheme
|
||||
defaultContentLanguage: en
|
||||
copyright: '© 2021 bbaovanc <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>'
|
||||
sectionPagesMenu: main
|
||||
enableRobotsTXT: true
|
||||
enableGitInfo: true
|
||||
|
||||
pagination:
|
||||
pagerSize: 5
|
||||
|
||||
taxonomies:
|
||||
_merge: deep
|
||||
|
||||
markup: # this just keeps the bobatheme markup styling
|
||||
_merge: deep
|
||||
|
||||
outputs:
|
||||
_merge: deep
|
||||
|
||||
outputFormats:
|
||||
_merge: deep
|
||||
|
||||
params:
|
||||
author:
|
||||
name: bbaovanc
|
||||
|
||||
# these are for the OpenGraph/Twitter embeds in Hugo
|
||||
description: Example website for bobatheme
|
||||
|
||||
# these are for favicons in bobatheme (disabled by default)
|
||||
# faviconSVG: favicon.svg
|
||||
# appleTouchPNG: apple-touch-icon.png
|
||||
|
||||
# show reading time (enabled by default)
|
||||
# readingtime: true
|
||||
|
||||
# used for "View source" (unset by default)
|
||||
# gitFileURL: https://github.com/BBaoVanC/bobatheme/blob/master
|
||||
# gitFileIcon: github-circle
|
||||
# gitHistoryURL: https://github.com/BBaoVanC/bobatheme/commits/master
|
||||
|
||||
# social media share icons
|
||||
# shareButtons:
|
||||
# twitter: true
|
||||
# facebook: true
|
||||
# linkedin: true
|
||||
# reddit: true
|
||||
# telegram: true
|
||||
# print: true
|
||||
|
||||
# show "Latest Posts" section at bottom of content pages
|
||||
# latestPostsOnContent: true
|
||||
|
||||
# footer: >-
|
||||
# Some example text for the footer.
|
||||
|
||||
|
||||
# see https://gohugo.io/about/hugo-and-gdpr/#all-privacy-settings
|
||||
# you probably want to keep this default
|
||||
privacy:
|
||||
_merge: deep
|
||||
|
||||
languages:
|
||||
en:
|
||||
languageName: English
|
||||
title: Example Website
|
||||
weight: 1
|
154
layouts/partials/_internal/pagination.html
Normal file
154
layouts/partials/_internal/pagination.html
Normal file
@ -0,0 +1,154 @@
|
||||
{{- $validFormats := slice "default" "terse" }}
|
||||
|
||||
{{- $msg1 := "When passing a map to the internal pagination template, one of the elements must be named 'page', and it must be set to the context of the current page." }}
|
||||
{{- $msg2 := "The 'format' specified in the map passed to the internal pagination template is invalid. Valid choices are: %s." }}
|
||||
|
||||
{{- $page := . }}
|
||||
{{- $format := "default" }}
|
||||
|
||||
{{- if reflect.IsMap . }}
|
||||
{{- with .page }}
|
||||
{{- $page = . }}
|
||||
{{- else }}
|
||||
{{- errorf $msg1 }}
|
||||
{{- end }}
|
||||
{{- with .format }}
|
||||
{{- $format = lower . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if in $validFormats $format }}
|
||||
{{- if gt $page.Paginator.TotalPages 1 }}
|
||||
<ul class="pagination pagination-{{ $format }}">
|
||||
{{- partial (printf "inline/pagination/%s.html" $format) $page }}
|
||||
</ul>
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- errorf $msg2 (delimit $validFormats ", ") }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Format: default
|
||||
{{/* --------------------------------------------------------------------- */}}
|
||||
{{- define "_partials/inline/pagination/default.html" }}
|
||||
{{- with .Paginator }}
|
||||
{{- $currentPageNumber := .PageNumber }}
|
||||
|
||||
{{- with .First }}
|
||||
{{- if ne $currentPageNumber .PageNumber }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="First" class="page-link" role="button"><span aria-hidden="true">««</span></a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item disabled">
|
||||
<a aria-disabled="true" aria-label="First" class="page-link" role="button" tabindex="-1"><span aria-hidden="true">««</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Prev }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Previous" class="page-link" role="button"><span aria-hidden="true">«</span></a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item disabled">
|
||||
<a aria-disabled="true" aria-label="Previous" class="page-link" role="button" tabindex="-1"><span aria-hidden="true">«</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
|
||||
{{- $slots := 5 }}
|
||||
{{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }}
|
||||
{{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }}
|
||||
{{- if lt (add (sub $end $start) 1) $slots }}
|
||||
{{- $start = math.Max 1 (add (sub $end $slots) 1) }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $k := seq $start $end }}
|
||||
{{- if eq $.Paginator.PageNumber $k }}
|
||||
<li class="page-item active">
|
||||
<a aria-current="page" aria-label="Page {{ $k }}" class="page-link" role="button">{{ $k }}</a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item">
|
||||
<a href="{{ (index $.Paginator.Pagers (sub $k 1)).URL }}" aria-label="Page {{ $k }}" class="page-link" role="button">{{ $k }}</a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Next }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Next" class="page-link" role="button"><span aria-hidden="true">»</span></a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item disabled">
|
||||
<a aria-disabled="true" aria-label="Next" class="page-link" role="button" tabindex="-1"><span aria-hidden="true">»</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
|
||||
{{- with .Last }}
|
||||
{{- if ne $currentPageNumber .PageNumber }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Last" class="page-link" role="button"><span aria-hidden="true">»»</span></a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item disabled">
|
||||
<a aria-disabled="true" aria-label="Last" class="page-link" role="button" tabindex="-1"><span aria-hidden="true">»»</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Format: terse
|
||||
{{/* --------------------------------------------------------------------- */}}
|
||||
{{- define "_partials/inline/pagination/terse.html" }}
|
||||
{{- with .Paginator }}
|
||||
{{- $currentPageNumber := .PageNumber }}
|
||||
|
||||
{{- with .First }}
|
||||
{{- if ne $currentPageNumber .PageNumber }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="First" class="page-link" role="button"><span aria-hidden="true">««</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Prev }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Previous" class="page-link" role="button"><span aria-hidden="true">«</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
|
||||
{{- $slots := 3 }}
|
||||
{{- $start := math.Max 1 (sub .PageNumber (math.Floor (div $slots 2))) }}
|
||||
{{- $end := math.Min .TotalPages (sub (add $start $slots) 1) }}
|
||||
{{- if lt (add (sub $end $start) 1) $slots }}
|
||||
{{- $start = math.Max 1 (add (sub $end $slots) 1) }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $k := seq $start $end }}
|
||||
{{- if eq $.Paginator.PageNumber $k }}
|
||||
<li class="page-item active">
|
||||
<a aria-current="page" aria-label="Page {{ $k }}" class="page-link" role="button">{{ $k }}</a>
|
||||
</li>
|
||||
{{- else }}
|
||||
<li class="page-item">
|
||||
<a href="{{ (index $.Paginator.Pagers (sub $k 1)).URL }}" aria-label="Page {{ $k }}" class="page-link" role="button">{{ $k }}</a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- with .Next }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Next" class="page-link" role="button"><span aria-hidden="true">»</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
|
||||
{{- with .Last }}
|
||||
{{- if ne $currentPageNumber .PageNumber }}
|
||||
<li class="page-item">
|
||||
<a href="{{ .URL }}" aria-label="Last" class="page-link" role="button"><span aria-hidden="true">»»</span></a>
|
||||
</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end -}}
|
@ -1,5 +1,6 @@
|
||||
{{ if gt .Paginator.TotalPages 1 }}
|
||||
<nav class="pagination">
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{/* https://github.com/gohugoio/hugo/blob/a88b488181279befd50e1d127f9f67604f2f9854/tpl/tplimpl/embedded/templates/_partials/pagination.html */}}
|
||||
{{ partial "_internal/pagination.html" . }}
|
||||
</nav>
|
||||
{{ end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user