report broken links
This commit is contained in:
parent
4eb19e8b3e
commit
d31e80f693
1 changed files with 13 additions and 8 deletions
|
@ -4,24 +4,29 @@
|
|||
|
||||
{{- $u := urls.Parse $destination -}}
|
||||
{{- if not $u.Scheme -}}
|
||||
{{- with site.GetPage .Destination -}}
|
||||
{{- $backlinks := .Store.Get "backlinks" | default slice -}}
|
||||
{{- $page := site.GetPage $destination -}}
|
||||
{{- if $page -}}
|
||||
{{- $backlinks := $page.Store.Get "backlinks" | default slice -}}
|
||||
{{- $backlinks := $backlinks|append $currentPage.RelPermalink -}}
|
||||
{{- .Store.Set "backlinks" ($backlinks|uniq) -}}
|
||||
{{- $page.Store.Set "backlinks" ($backlinks|uniq) -}}
|
||||
{{- if not $text -}}
|
||||
{{- $text = .LinkTitle -}}
|
||||
{{- $text = $page.LinkTitle -}}
|
||||
{{- end -}}
|
||||
<span class="supt">{{- .Section -}}⁄</span><a href="{{- .RelPermalink -}}" {{- with .Title }} title="{{ . }}"{{ end -}}>{{- $text -}}</a>
|
||||
{{- end -}}
|
||||
{{- if hasPrefix $destination "/library" -}}
|
||||
<span class="supt">{{- $page.Section -}}⁄</span><a href="{{- $page.RelPermalink -}}" {{- with $page.Title }} title="{{ . }}"{{ end -}}>{{- $text -}}</a>
|
||||
{{- else if hasPrefix $destination "/library/" -}}
|
||||
{{- $bib := strings.TrimPrefix "/library/" $destination -}}
|
||||
{{- $b := index site.Data.books.catalog $bib -}}
|
||||
{{- if not $b.title -}}
|
||||
{{- warnf "In %s bib:%s not found." $currentPage.RelPermalink $bib -}}
|
||||
{{- end -}}
|
||||
{{- if not $text -}}
|
||||
{{- $text = $b.title|default "" -}}
|
||||
{{- end -}}
|
||||
<span class="supt">library⁄</span><a href="/library/BROWSE_LIBRARY.html#/books/{{- $bib -}}">{{- $text -}}</a>
|
||||
{{- else -}}
|
||||
{{- warnf "In %s broken link: %s" $currentPage.RelPermalink $destination -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
<span class="supt">www⁄</span><a href="{{ .Destination | safeURL }}"{{- with .Title }} title="{{ . }}"{{ end -}}{{- if $u.IsAbs }} rel="external"{{ end -}}>{{- with .Text }}{{ . }}{{- end -}}</a>
|
||||
<span class="supt">www⁄</span><a href="{{ .Destination | safeURL }}"{{- with .Title }} title="{{ . }}"{{ end -}}{{- if $u.IsAbs }} rel="external"{{ end -}}>{{- if .Text }}{{ .Text }}{{- else -}}{{- .Destination -}}{{- end -}}</a>
|
||||
{{- end -}}
|
||||
{{- /* chomp trailing newline */ -}}
|
||||
|
|
Loading…
Add table
Reference in a new issue