Correction des liens morts
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
{{- $url := "" -}}
|
||||
{{- $report := dict -}}
|
||||
{{- $report := partial "external-links-report.html" (dict) -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- with index . "URL" -}}
|
||||
{{- $url = . -}}
|
||||
{{- end -}}
|
||||
{{- with index . "Report" -}}
|
||||
{{- $report = . -}}
|
||||
{{- $report = partial "external-links-report.html" (dict "Report" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -89,6 +89,12 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $statusChecked "") (gt (len $deadInfo) 0) -}}
|
||||
{{- with index $deadInfo "checkedAt" -}}
|
||||
{{- $statusChecked = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if gt $statusCode 0 -}}
|
||||
{{- if lt $statusCode 400 -}}
|
||||
{{- $statusTone = "ok" -}}
|
||||
|
||||
58
themes/2026/layouts/_partials/external-links-report.html
Normal file
58
themes/2026/layouts/_partials/external-links-report.html
Normal file
@@ -0,0 +1,58 @@
|
||||
{{- $reportPath := "data/external_links.yaml" -}}
|
||||
{{- $report := dict -}}
|
||||
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- with index . "ReportPath" -}}
|
||||
{{- $reportPath = . -}}
|
||||
{{- end -}}
|
||||
{{- with index . "Report" -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
{{- else if . -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq (len $report) 0 -}}
|
||||
{{- if eq $reportPath "data/external_links.yaml" -}}
|
||||
{{- with index site.Data "external_links" -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
{{- else if fileExists $reportPath -}}
|
||||
{{- $report = transform.Unmarshal (readFile $reportPath) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $sourceLinks := slice -}}
|
||||
{{- with index $report "deadLinks" -}}
|
||||
{{- $sourceLinks = . -}}
|
||||
{{- end -}}
|
||||
{{- if and (eq (len $sourceLinks) 0) (isset $report "links") -}}
|
||||
{{- $sourceLinks = default (slice) (index $report "links") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $links := slice -}}
|
||||
{{- range $sourceLinks -}}
|
||||
{{- $status := "" -}}
|
||||
{{- with index . "status" -}}
|
||||
{{- $status = printf "%v" . -}}
|
||||
{{- end -}}
|
||||
{{- if eq $status "" -}}
|
||||
{{- with index . "code" -}}
|
||||
{{- $status = printf "%v" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $links = $links | append (dict
|
||||
"url" (default "" (index . "url"))
|
||||
"status" $status
|
||||
"locations" (default (slice) (index . "locations"))
|
||||
"errorType" (default "" (index . "errorType"))
|
||||
"checkedAt" (default "" (index . "checkedAt"))
|
||||
) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return (dict
|
||||
"generatedAt" (default "" (index $report "generatedAt"))
|
||||
"entries" (default (dict) (index $report "entries"))
|
||||
"links" $links
|
||||
) -}}
|
||||
@@ -1,14 +1,4 @@
|
||||
{{- $defaultReportPath := "data/external_links.yaml" -}}
|
||||
{{- $reportPath := default $defaultReportPath .ReportPath -}}
|
||||
{{- $report := default (dict) .Report -}}
|
||||
{{- if or (eq (len $report) 0) (not (isset $report "links")) -}}
|
||||
{{- if fileExists $reportPath -}}
|
||||
{{- $report = transform.Unmarshal (readFile $reportPath) -}}
|
||||
{{- else -}}
|
||||
{{- warnf "Rapport des liens morts introuvable (%s)" $reportPath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $report := partial "external-links-report.html" . -}}
|
||||
{{- $allPages := where site.Pages ".File" "!=" nil -}}
|
||||
{{- $links := default (slice) $report.links -}}
|
||||
{{- $generatedLabel := "" -}}
|
||||
@@ -39,9 +29,22 @@
|
||||
{{- $locations := default (slice) .locations -}}
|
||||
{{- if gt (len $locations) 0 -}}
|
||||
{{- range $locations -}}
|
||||
{{- $file := .file -}}
|
||||
{{- $line := .line -}}
|
||||
{{- $pagePath := .page -}}
|
||||
{{- $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 -}}
|
||||
@@ -60,6 +63,8 @@
|
||||
<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 -}}
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
{{- $excludeInterestingLinks := false -}}
|
||||
{{- $groupBySubSections := false -}}
|
||||
{{- $subSections := slice -}}
|
||||
{{- $externalLinksReport := dict -}}
|
||||
{{- if fileExists "tools/cache/external_links.yaml" -}}
|
||||
{{- $externalLinksReport = transform.Unmarshal (readFile "tools/cache/external_links.yaml") -}}
|
||||
{{- end -}}
|
||||
{{- $externalLinksReport := partial "external-links-report.html" (dict) -}}
|
||||
{{- with $context -}}
|
||||
{{- if eq (strings.TrimSuffix "/" .RelPermalink) "/interets" -}}
|
||||
{{- $excludeInterestingLinks = true -}}
|
||||
|
||||
@@ -49,10 +49,7 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $report := dict -}}
|
||||
{{- if fileExists "tools/cache/external_links.yaml" -}}
|
||||
{{- $report = transform.Unmarshal (readFile "tools/cache/external_links.yaml") -}}
|
||||
{{- end -}}
|
||||
{{- $report := partial "external-links-report.html" (dict) -}}
|
||||
{{- $deadList := default (slice) (index $report "links") -}}
|
||||
{{- $entriesMap := default (dict) (index $report "entries") -}}
|
||||
{{- $cacheEntry := index $entriesMap .Destination -}}
|
||||
|
||||
Reference in New Issue
Block a user