Merge pull request #1538 from mnjm/order-by-weight

 Articles ordering by weight
This commit is contained in:
Nuno Coração 2024-06-19 17:38:32 +01:00 committed by GitHub
commit 5ccc8c23cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 45 additions and 47 deletions

View file

@ -88,6 +88,7 @@ disableTextInHeader = false
showLikes = false
showTableOfContents = false
showCards = false
orderByWeight = false
groupByYear = true
cardView = false
cardViewScreenWidth = false

View file

@ -87,6 +87,7 @@ smartTOCHideUnfocusedChildren = false
showLikes = false
showTableOfContents = true
showCards = true
orderByWeight = false
groupByYear = false
cardView = true
cardViewScreenWidth = false

View file

@ -258,6 +258,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `list.showViews` | `false` | Whether or not list views are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showLikes` | `false` | Whether or not list likes are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showCards` | `false` | Whether or not each article is displayed as a card or as simple inline text. |
| `list.orderByWeight` | `false` | Whether or not articles are sorted by [weights](https://gohugo.io/methods/page/weight/). |
| `list.groupByYear` | `true` | Whether or not articles are grouped by year on list pages. |
| `list.cardView` | `false` | Display lists as a gallery of cards. |
| `list.cardViewScreenWidth` | `false` | Enhance the width of card galleries in lists to take the full width available. |

View file

@ -258,6 +258,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `list.showViews` | `false` | Whether or not list views are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showLikes` | `false` | Whether or not list likes are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showCards` | `false` | Whether or not each article is displayed as a card or as simple inline text. |
| `list.orderByWeight` | `false` | Whether or not articles are sorted by [weights](https://gohugo.io/methods/page/weight/). |
| `list.groupByYear` | `true` | Whether or not articles are grouped by year on list pages. |
| `list.cardView` | `false` | Display lists as a gallery of cards. |
| `list.cardViewScreenWidth` | `false` | Enhance the width of card galleries in lists to take the full width available. |

View file

@ -259,6 +259,7 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `list.showViews` | `false` | Whether or not list views are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showLikes` | `false` | Whether or not list likes are displayed. This requires firebase integrations to be enabled, look below. |
| `list.showCards` | `false` | Whether or not each article is displayed as a card or as simple inline text. |
| `list.orderByWeight` | `false` | Whether or not articles are sorted by [weights](https://gohugo.io/methods/page/weight/). |
| `list.groupByYear` | `true` | Whether or not articles are grouped by year on list pages. |
| `list.cardView` | `false` | Display lists as a gallery of cards. |
| `list.cardViewScreenWidth` | `false` | Enhance the width of card galleries in lists to take the full width available. |

View file

@ -51,7 +51,7 @@
<div class="min-w-0 min-h-0 max-w-prose">
{{ .Content }}
</div>
@ -61,80 +61,73 @@
{{ $cardView := .Params.cardView | default (.Site.Params.list.cardView | default false) }}
{{ $cardViewScreenWidth := .Params.cardViewScreenWidth | default (.Site.Params.list.cardViewScreenWidth | default false) }}
{{ $groupByYear := .Params.groupByYear | default ($.Site.Params.list.groupByYear | default false) }}
{{ $orderByWeight := .Params.orderByWeight | default ($.Site.Params.list.orderByWeight | default false) }}
{{ $groupByYear := and (not $orderByWeight) $groupByYear }}
{{ if not $cardView }}
<section class="space-y-10 w-full">
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ if $groupByYear }}
<h2 class="mt-12 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
{{ end }}
{{ range .Pages }}
{{ partial "article-link/simple.html" . }}
{{ end }}
{{ if not $orderByWeight }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ if $groupByYear }}
<h2 class="mt-12 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
{{ end }}
{{ range .Pages }}
{{ partial "article-link/simple.html" . }}
{{ end }}
{{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/simple.html" . }}
{{ end }}
{{ end }}
</section>
{{ else if and $cardView (not $cardViewScreenWidth) }}
{{ else }}
{{ if $groupByYear }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3">
{{ if $cardViewScreenWidth }}
<div class="relative w-screen max-w-[1600px] px-[30px]" style="left: calc(max(-50vw,-800px) + 50%);">
{{ end }}
<h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 {{ if $cardViewScreenWidth }} xl:grid-cols-4 2xl:grid-cols-5 {{ end }}">
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
</section>
{{ if $cardViewScreenWidth }} </div> {{ end }}
{{ end }}
{{ else }}
{{ else }}
{{ if $cardViewScreenWidth }}
<div class="relative w-screen max-w-[1600px] px-[30px]" style="left: calc(max(-50vw,-800px) + 50%);">
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
{{ else }}
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3">
{{ end }}
{{ if not $orderByWeight }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
{{ else }}
{{ range (.Paginate (.Pages.ByWeight)).Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
</section>
{{ if $cardViewScreenWidth }} </div> {{ end }}
{{ end }}
{{ else if and $cardView $cardViewScreenWidth }}
{{ if $groupByYear }}
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
<div class="relative w-screen max-w-[1600px] px-[30px]" style="left: calc(max(-50vw,-800px) + 50%);">
<h2 class="mt-12 mb-3 text-2xl font-bold text-neutral-700 first:mt-8 dark:text-neutral-300">
{{ .Key }}
</h2>
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
</section>
</div>
{{ end }}
{{ else }}
<div class="relative w-screen max-w-[1600px] px-[30px]" style="left: calc(max(-50vw,-800px) + 50%);">
<section class="w-full grid gap-4 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">
{{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }}
{{ range .Pages }}
{{ partial "article-link/card.html" . }}
{{ end }}
{{ end }}
</section>
</div>
{{ end }}
{{end}}
{{ else }}