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

74 lines
2.6 KiB
HTML

{{- $report := partial "external-links-report.html" . -}}
{{- $allPages := where site.Pages ".File" "!=" nil -}}
{{- $links := default (slice) $report.links -}}
{{- $linkCount := len $links -}}
{{- $generatedLabel := "" -}}
{{- with $report.generatedAt -}}
{{- $ts := time . -}}
{{- $generatedLabel = $ts.Format "02/01/2006" -}}
{{- end -}}
<div aria-label="Statistiques" class="stats">
{{ partial "stat.html" (dict "title" "Dernière mise à jour" "value" $generatedLabel)}}
{{ partial "stat.html" (dict "title" "Liens morts détectés" "value" $linkCount)}}
</div>
<div class="table-wrapper">
<table>
<thead>
<tr>
<th>Emplacements</th>
<th>URL</th>
<th>Code</th>
<th>Détails</th>
</tr>
</thead>
<tbody>
{{- range $links }}
<tr>
<td>
{{- $locations := default (slice) .locations -}}
{{- if gt (len $locations) 0 -}}
{{- range $locations }}
{{- $file := .file -}}
{{- $line := .line -}}
{{- $pagePath := .page -}}
{{- $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 -}}
<em>Emplacement inconnu</em>
{{- end -}}
<br />
{{- end }}
{{- else -}}
<em>Emplacements inconnus</em>
{{- end -}}
</td>
<td>
<a href="{{ .url }}" rel="noreferrer noopener" target="_blank">{{ .url }}</a>
</td>
<td>{{ with .code }}<code>{{ . }}</code>{{ end }}</td>
<td>{{ with .statusText }}<code>{{ . }}</code>{{ end }}</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</div>