diff --git a/hugo.toml b/hugo.toml index 5363e56..737d689 100644 --- a/hugo.toml +++ b/hugo.toml @@ -2,6 +2,7 @@ baseURL = 'https://example.org/' languageCode = 'en-us' title = 'Chirpy' enableGitInfo = true +paginate = 5 # 每页显示的文章数量 [taxonomies] category = "categories" diff --git a/layouts/index.html b/layouts/index.html index 202d2ed..e75e36a 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -7,7 +7,7 @@ {{ $pinned_size := 0 }} - {{ $paginator := .Paginate $all_normal }} + {{ $paginator := .Paginate $all_posts }} {{ $visible_start := sub $paginator.PageNumber 1 | mul $paginator.PagerSize }} {{ $visible_end := add $visible_start $paginator.PagerSize }} @@ -24,7 +24,7 @@ {{ end }} - {{ $normal_size := sub (len $paginator.Pages) $pinned_size }} + {{ $normal_size := sub $paginator.PagerSize $pinned_size }} {{ if gt $normal_size 0 }} {{ $normal_start := 0 }} @@ -121,6 +121,6 @@ {{ if gt $paginator.TotalPages 1 }} - {{ partial "pagination.html" . }} + {{ partial "post-paginator.html" . }} {{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/partials/post-paginator.html b/layouts/partials/post-paginator.html new file mode 100644 index 0000000..fdbcd03 --- /dev/null +++ b/layouts/partials/post-paginator.html @@ -0,0 +1,77 @@ + + + \ No newline at end of file