{{- $defaultReportPath := "tools/cache/external_links.yaml" -}} {{- $reportPath := default $defaultReportPath .ReportPath -}} {{- $report := default (dict) .Report -}} {{- if or (eq (len $report) 0) (not (isset $report "links")) -}} {{- if fileExists $reportPath -}} {{- with readFile $reportPath -}} {{- $report = . | unmarshal -}} {{- end -}} {{- else -}} {{- warnf "Rapport des liens morts introuvable (%s)" $reportPath -}} {{- end -}} {{- end -}} {{- $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 -}}
| URL | Emplacements | Statut |
|---|---|---|
| {{ .url }} |
{{- $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 -}}
{{ $matchedPage.Title }}
{{- else if $file -}}
{{ $file }}{{ if $line }}:{{ $line }}{{ end }}
{{- else -}}
Emplacement inconnu
{{- end -}}
{{- end }} {{- else -}} Emplacements inconnus {{- end -}} |
{{ .status }} |