1

Harmoniser les asides et le rendu des articles

Closes #5

Closes #6

Closes #8

Closes #9

Closes #10
This commit is contained in:
2026-04-05 15:07:52 +02:00
parent edc6f3def5
commit 67717fdb7b
17 changed files with 279 additions and 227 deletions

View File

@@ -1,16 +1,28 @@
{{- $complementaryFilesMarkup := strings.TrimSpace (partial "asides/complementary-images.html" .) -}}
{{- $commentsMarkup := strings.TrimSpace (partial "asides/comments.html" .) -}}
{{- $keywordsMarkup := strings.TrimSpace (partial "asides/keywords.html" .) -}}
{{- $dossierMarkup := strings.TrimSpace (partial "asides/dossier.html" .) -}}
{{- $changeHistoryMarkup := strings.TrimSpace (partial "article-change-history.html" .) -}}
{{- $furtherReadingMarkup := strings.TrimSpace (partial "article-further-reading.html" .) -}}
{{- $relatedMarkup := strings.TrimSpace (partial "article-related.html" .) -}}
{{- if or (ne $commentsMarkup "") (ne $keywordsMarkup "") (ne $changeHistoryMarkup "") (ne $furtherReadingMarkup "") (ne $relatedMarkup "") -}}
{{- if or (ne $complementaryFilesMarkup "") (ne $commentsMarkup "") (ne $keywordsMarkup "") (ne $dossierMarkup "") (ne $changeHistoryMarkup "") (ne $furtherReadingMarkup "") (ne $relatedMarkup "") -}}
<section class="article-asides">
{{- with $complementaryFilesMarkup -}}
{{- . | safeHTML -}}
{{- end -}}
{{- if or (ne $commentsMarkup "") (ne $keywordsMarkup "") -}}
<div class="article-asides-grid">
{{- with $commentsMarkup -}}
{{- . | safeHTML -}}
{{- end -}}
{{- with $keywordsMarkup -}}
{{- . | safeHTML -}}
{{- end -}}
</div>
{{- end -}}
{{- with $dossierMarkup -}}
{{- . | safeHTML -}}
{{- end -}}
{{- with $furtherReadingMarkup -}}
{{- . | safeHTML -}}
{{- end -}}

View File

@@ -1,49 +1 @@
{{- $page := . -}}
{{- with $page.Params.dossier -}}
{{- $dossierID := index . 0 -}}
{{- if $dossierID -}}
{{- $group := where site.RegularPages "Params.dossier" "intersect" (slice $dossierID) -}}
{{- $sorted := sort $group "RelPermalink" "asc" -}}
{{- $sorted = sort $sorted "Date" "asc" -}}
{{- $sorted = sort $sorted "Weight" "asc" -}}
{{- if gt (len $sorted) 1 -}}
{{- $scratch := newScratch -}}
{{- $scratch.Set "index" -1 -}}
{{- range $i, $item := $sorted -}}
{{- if eq $item.Permalink $page.Permalink -}}
{{- $scratch.Set "index" $i -}}
{{- end -}}
{{- end -}}
{{- $index := $scratch.Get "index" -}}
{{- if ge $index 0 -}}
{{- $prev := false -}}
{{- $next := false -}}
{{- if gt $index 0 -}}
{{- $prev = index $sorted (sub $index 1) -}}
{{- end -}}
{{- if lt (add $index 1) (len $sorted) -}}
{{- $next = index $sorted (add $index 1) -}}
{{- end -}}
<footer class="article-footer">
<nav class="article-footer-dossier-nav" aria-label="Navigation dans le dossier">
<p class="article-footer-dossier-nav-label"><span>Dossier</span><strong>{{ $dossierID }}</strong></p>
<div class="article-footer-dossier-nav-links">
{{- with $prev -}}
<p class="article-footer-dossier-nav-link article-footer-dossier-nav-link-prev">
<span>Page précédente</span>
<a href="{{ .RelPermalink }}" title="{{ .Title }}">{{ .Title }}</a>
</p>
{{- end -}}
{{- with $next -}}
<p class="article-footer-dossier-nav-link article-footer-dossier-nav-link-next">
<span>Page suivante</span>
<a href="{{ .RelPermalink }}" title="{{ .Title }}">{{ .Title }}</a>
</p>
{{- end -}}
</div>
</nav>
</footer>
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/* L'ancienne pagination simple de dossier a été supprimée au profit du sommaire de dossier. */}}

View File

@@ -87,40 +87,38 @@
{{- end -}}
{{- if gt (len $unusedImages) 0 -}}
<aside class="article-complementary-images">
<section>
<h2>Images complémentaires</h2>
<ul>
{{- range $unusedImages -}}
{{- $imageName := path.Base .Name -}}
{{- $imageStem := $imageName | replaceRE "\\.[^.]+$" "" -}}
{{- $data := dict -}}
{{- $dataFile := $page.Resources.Get (printf "data/images/%s.yaml" $imageStem) -}}
{{- if not $dataFile -}}
{{- $dataFile = $page.Resources.Get (printf "data/%s.yaml" $imageStem) -}}
{{- end -}}
{{- if $dataFile -}}
{{- with $dataFile.Content | transform.Unmarshal -}}
{{- $data = . -}}
{{- end -}}
{{- end -}}
{{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}}
{{- $thumbnail := . -}}
{{- if and (ne .MediaType.SubType "svg") (gt .Width 360) -}}
{{- $thumbnail = partial "media/process-image.html" (dict
"image" .
"action" "Resize"
"spec" "360x"
) -}}
{{- end -}}
<li>
<a href="{{ .RelPermalink }}" title="{{ $title }}">
<img src="{{ $thumbnail.RelPermalink }}" alt="{{ $title }}" loading="lazy" decoding="async">
</a>
</li>
<section class="article-aside-block article-complementary-files">
<h2>Fichiers complémentaires</h2>
<ul>
{{- range $unusedImages -}}
{{- $imageName := path.Base .Name -}}
{{- $imageStem := $imageName | replaceRE "\\.[^.]+$" "" -}}
{{- $data := dict -}}
{{- $dataFile := $page.Resources.Get (printf "data/images/%s.yaml" $imageStem) -}}
{{- if not $dataFile -}}
{{- $dataFile = $page.Resources.Get (printf "data/%s.yaml" $imageStem) -}}
{{- end -}}
</ul>
</section>
</aside>
{{- if $dataFile -}}
{{- with $dataFile.Content | transform.Unmarshal -}}
{{- $data = . -}}
{{- end -}}
{{- end -}}
{{- $title := default (printf "Image complémentaire : %s" $imageName) (index $data "title") -}}
{{- $thumbnail := . -}}
{{- if and (ne .MediaType.SubType "svg") (gt .Width 360) -}}
{{- $thumbnail = partial "media/process-image.html" (dict
"image" .
"action" "Resize"
"spec" "360x"
) -}}
{{- end -}}
<li>
<a href="{{ .RelPermalink }}" title="{{ $title }}">
<img src="{{ $thumbnail.RelPermalink }}" alt="{{ $title }}" loading="lazy" decoding="async">
</a>
</li>
{{- end -}}
</ul>
</section>
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,13 @@
{{- $dossierTitle := "Dossier" -}}
{{- with .Params.dossier -}}
{{- with index . 0 -}}
{{- $dossierTitle = strings.TrimSpace . -}}
{{- end -}}
{{- end -}}
{{- $summary := strings.TrimSpace (partial "dossier-summary.html" (dict "Page" . "ShowTitle" false)) -}}
{{- if ne $summary "" -}}
<section class="article-aside-block article-dossier-summary">
<h2>{{ $dossierTitle }}</h2>
{{- $summary | safeHTML -}}
</section>
{{- end -}}

View File

@@ -1,8 +1,12 @@
{{- $current := . -}}
{{- $showTitle := true -}}
{{- if reflect.IsMap . -}}
{{- with index . "Page" -}}
{{- $current = . -}}
{{- end -}}
{{- if isset . "ShowTitle" -}}
{{- $showTitle = index . "ShowTitle" -}}
{{- end -}}
{{- end -}}
{{- with $current.Params.dossier -}}
@@ -15,12 +19,14 @@
{{- $sorted = sort $sorted "Weight" "asc" -}}
{{- if gt (len $sorted) 1 -}}
<nav aria-label="Sommaire du dossier">
{{- if $showTitle -}}
<p><strong>{{ $dossierID }}</strong></p>
{{- end -}}
<ol>
{{- range $sorted -}}
<li>
<li{{ if eq .Permalink $current.Permalink }} class="is-current"{{ end }}>
{{- if eq .Permalink $current.Permalink -}}
<strong>{{ .Title }}</strong>
<strong aria-current="page">{{ .Title }}</strong>
{{- else -}}
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- end -}}

View File

@@ -0,0 +1,4 @@
{{- $content := .Content -}}
{{- $content = replace $content `<details class="update">` `<details class="update" open>` -}}
{{- $content = replace $content `<details class='update'>` `<details class='update' open>` -}}
{{- return ($content | safeHTML) -}}

View File

@@ -2,7 +2,7 @@
{{ partial "article-header.html" . }}
<main>
<article>
{{ .Content }}
{{ partial "rendered-content.html" . }}
{{ partial "article-books.html" . }}
{{ partial "article-footer.html" . }}
</article>

View File

@@ -2,7 +2,7 @@
{{ partial "article-header.html" . }}
<main>
<article>
{{ .Content }}
{{ partial "rendered-content.html" . }}
{{ partial "liens-morts/report.html" (dict "Page" .) }}
{{ partial "article-footer.html" . }}
</article>

View File

@@ -2,12 +2,11 @@
{{ partial "article-header.html" . }}
<main>
<article>
{{ .Content }}
{{ partial "rendered-content.html" . }}
{{ partial "article-books.html" . }}
{{ partial "article-asides.html" . }}
{{ partial "article-footer.html" . }}
</article>
{{ partial "asides/complementary-images.html" . }}
{{ partial "asides/toc.html" . }}
</main>
{{ end }}

View File

@@ -4,7 +4,7 @@
{{- $pages := .RegularPagesRecursive.ByDate.Reverse -}}
{{ with .Content }}
<article>
{{ . }}
{{ partial "rendered-content.html" $ }}
</article>
{{ end }}

View File

@@ -2,7 +2,7 @@
{{ partial "article-header.html" . }}
<main>
<article>
{{ .Content }}
{{ partial "rendered-content.html" . }}
<section>
<header><h2>Taxonomies</h2></header>

View File

@@ -3,7 +3,7 @@
<main class="taxonomy-page">
{{ with .Content }}
<article>
{{ . }}
{{ partial "rendered-content.html" $ }}
</article>
{{ end }}

View File

@@ -4,7 +4,7 @@
{{- $pages := .Pages.ByDate.Reverse -}}
{{ with .Content }}
<article>
{{ . }}
{{ partial "rendered-content.html" $ }}
</article>
{{ end }}