Skip to content

Commit

Permalink
Merge pull request monkeyWzr#9 from Nizzlay/disable-pagination
Browse files Browse the repository at this point in the history
Create option to disable pagination in archive
  • Loading branch information
monkeyWzr authored Jul 5, 2021
2 parents 53e9abe + faf1807 commit b0411f6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ for example, `data/projects.json`:
}
```

## Social media links
### Social media links

```toml
[[params.social]]
Expand Down Expand Up @@ -262,6 +262,14 @@ mathjax: true # or false
The site config will be ignored when `mathjax` option exists in front matter.

### Archive
Pagination on posts archive can be disabled to show all posts in chronological order

```toml
[params]
showAllPostsArchive = true # or false (default)
```

## TODOS

- [ ] More comments engines
Expand Down
1 change: 1 addition & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ weight = 4
colortheme = "white" # dark, light, white, or classic
rss = true # generate rss feed. default value is false
googleAnalyticsAsync = true # use asynchronous tracking. Synchronous tracking by default
showAllPostsArchive = false # default

# Home page settings
description = "Hugo is a general-purpose website framework. Technically speaking, Hugo is a static site generator. Unlike systems that dynamically build a page with each visitor request, Hugo builds pages when you create or update your content. Since websites are viewed far more often than they are edited, Hugo is designed to provide an optimal viewing experience for your website’s end users and an ideal writing experience for website authors."
Expand Down
12 changes: 10 additions & 2 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{{ define "main"}}
<div id="archive">
<ul class="post-list">
{{ range (sort .Paginator.Pages "Date" "desc") }}

{{ $pages := .Paginator.Pages }}
{{ if .Site.Params.showAllPostsArchive }}
{{ $pages = .Pages }}
{{ end }}

{{ range (sort $pages "Date" "desc") }}
{{ $pageYear := (.Date.Format "2006") }}
{{ if (ne $pageYear ($.Scratch.Get "year")) }}
{{ $.Scratch.Set "year" $pageYear }}
Expand All @@ -17,6 +23,8 @@ <h2>{{ $pageYear }}</h2>
</li>
{{ end }}
</ul>
{{ partial "pagination.html" . }}
{{ if eq .Site.Params.showAllPostsArchive false }}
{{ partial "pagination.html" . }}
{{ end }}
</div>
{{ end }}

0 comments on commit b0411f6

Please sign in to comment.