Correction des liens morts
This commit is contained in:
@@ -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 -}}
|
||||
|
||||
Reference in New Issue
Block a user