From 700e10c62fe4d757641d9fddea0ac95b5d2f361d Mon Sep 17 00:00:00 2001 From: Huy Tran Date: Wed, 12 Sep 2018 12:34:45 +1000 Subject: [PATCH] adds pagination for index page --- layouts/index.html | 23 +++++++++---------- layouts/partials/pagination.html | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 layouts/partials/pagination.html diff --git a/layouts/index.html b/layouts/index.html index 202ad80..e508122 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -4,11 +4,12 @@ {{ define "content" }}
- {{ range (where .Data.Pages "Type" "not in" (slice "about" "portfolio")).GroupBy "Section" }} - {{ range .Pages }} + {{ $paginator := .Paginate (where .Data.Pages "Type" "posts") }} + {{ range $paginator.Pages }}
- {{ .Title }}{{ if .Draft }} {{ end }} + {{ .Title }} + {{ if .Draft }}{{ end }} {{ .Date.Format (.Site.Params.dateformat | default "Jan 02, 2006") }} @@ -19,20 +20,18 @@ {{ .Summary }} {{ end }} {{ if .Truncated }} - + ... {{ end }}
- {{ end }} {{ end }}
+ {{ partial "pagination.html" . }} {{ end }} {{ define "footer" }} -{{ if .Site.GoogleAnalytics }} - - {{ template "_internal/google_analytics_async.html" . }} -{{ end }} -{{ partial "footer/font-awesome-js.html" . }} + {{ if .Site.GoogleAnalytics }} + + {{ template "_internal/google_analytics_async.html" . }} + {{ end }} + {{ partial "footer/font-awesome-js.html" . }} {{ end }} diff --git a/layouts/partials/pagination.html b/layouts/partials/pagination.html new file mode 100644 index 0000000..7995061 --- /dev/null +++ b/layouts/partials/pagination.html @@ -0,0 +1,39 @@ +{{ $pag := $.Paginator }} +{{ if gt $pag.TotalPages 1 }} + +{{ end }} \ No newline at end of file