1
Files
2025/themes/2026/layouts/_partials/liens-morts/report.html

82 lines
2.6 KiB
HTML

{{- $report := partial "external-links-report.html" . -}}
{{- $allPages := where site.Pages ".File" "!=" nil -}}
{{- $links := default (slice) $report.links -}}
{{- $generatedLabel := "" -}}
{{- with $report.generatedAt -}}
{{- $generatedLabel = (time .).Format "02/01/2006" -}}
{{- end -}}
<dl>
<dt>Dernière mise à jour</dt>
<dd>{{ $generatedLabel }}</dd>
<dt>Liens morts détectés</dt>
<dd>{{ len $links }}</dd>
</dl>
<table>
<thead>
<tr>
<th>URL</th>
<th>Emplacements</th>
<th>Statut</th>
</tr>
</thead>
<tbody>
{{- range $links -}}
<tr>
<td><a href="{{ .url }}" rel="noreferrer noopener" target="_blank">{{ .url }}</a></td>
<td>
{{- $locations := default (slice) .locations -}}
{{- if gt (len $locations) 0 -}}
{{- range $locations -}}
{{- $file := "" -}}
{{- $line := "" -}}
{{- $pagePath := "" -}}
{{- if reflect.IsMap . -}}
{{- with index . "file" -}}
{{- $file = printf "%v" . -}}
{{- end -}}
{{- with index . "line" -}}
{{- $line = printf "%v" . -}}
{{- end -}}
{{- with index . "page" -}}
{{- $pagePath = printf "%v" . -}}
{{- end -}}
{{- else -}}
{{- $pagePath = printf "%v" . -}}
{{- end -}}
{{- $matchedPage := false -}}
{{- if $pagePath -}}
{{- $candidate := site.GetPage $pagePath -}}
{{- if $candidate -}}
{{- $matchedPage = $candidate -}}
{{- end -}}
{{- end -}}
{{- if and (not $matchedPage) $file -}}
{{- $normalized := replaceRE "^content/" "" $file -}}
{{- $candidates := where $allPages "File.Path" $normalized -}}
{{- if gt (len $candidates) 0 -}}
{{- $matchedPage = index $candidates 0 -}}
{{- end -}}
{{- end -}}
{{- if $matchedPage -}}
<a href="{{ $matchedPage.RelPermalink }}">{{ $matchedPage.Title }}</a>
{{- else if $file -}}
<code>{{ $file }}{{ if $line }}:{{ $line }}{{ end }}</code>
{{- else if $pagePath -}}
<code>{{ $pagePath }}</code>
{{- else -}}
<em>Emplacement inconnu</em>
{{- end -}}
<br>
{{- end -}}
{{- else -}}
<em>Emplacements inconnus</em>
{{- end -}}
</td>
<td><code>{{ .status }}</code></td>
</tr>
{{- end -}}
</tbody>
</table>