Ajout des liens wikipédia dans les taxonomies
This commit is contained in:
@@ -3,5 +3,5 @@
|
|||||||
<div class="page-meta">
|
<div class="page-meta">
|
||||||
{{ partial "breadcrumbs.html" . }}
|
{{ partial "breadcrumbs.html" . }}
|
||||||
</div>
|
</div>
|
||||||
<h1>{{ .Title }}</h1>
|
<h1>{{ .Title }}</h1>{{ partial "page-links.html" . }}
|
||||||
</header>
|
</header>
|
||||||
@@ -1,7 +1,39 @@
|
|||||||
{{- $page := . -}}
|
{{- $page := . -}}
|
||||||
{{- with .Params.links }}
|
{{- $linksParam := .Params.links -}}
|
||||||
|
{{- $links := slice -}}
|
||||||
|
{{- if $linksParam }}
|
||||||
|
{{- $type := printf "%T" $linksParam -}}
|
||||||
|
{{- if hasPrefix $type "[]" }}
|
||||||
|
{{- $links = $linksParam -}}
|
||||||
|
{{- else }}
|
||||||
|
{{- $links = slice $linksParam -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- $hasWikipediaLink := false -}}
|
||||||
|
{{- range $links }}
|
||||||
|
{{- if and (not $hasWikipediaLink) (and .url (in .url "wikipedia.org")) }}
|
||||||
|
{{- $hasWikipediaLink = true -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- $addWikiLink := and (eq .Kind "term") (not $hasWikipediaLink) -}}
|
||||||
|
{{- $wikiLink := dict -}}
|
||||||
|
{{- if $addWikiLink }}
|
||||||
|
{{- $lang := default "fr" $page.Site.Language.Lang -}}
|
||||||
|
{{- $query := urlquery $page.Title -}}
|
||||||
|
{{- $searchUrl := printf "https://%s.wikipedia.org/w/index.php?search=%s" $lang $query -}}
|
||||||
|
{{- $wikiLink = dict
|
||||||
|
"name" (printf "Rechercher \"%s\" sur Wikipédia" $page.Title)
|
||||||
|
"url" $searchUrl
|
||||||
|
"lang" $lang
|
||||||
|
"require_manual_intervention" true
|
||||||
|
-}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if or (gt (len $links) 0) $addWikiLink }}
|
||||||
<nav id="page-links">
|
<nav id="page-links">
|
||||||
{{- range . }}
|
{{- range $links }}
|
||||||
{{- $text := default .name .text -}}
|
{{- $text := default .name .text -}}
|
||||||
{{- $title := default $text .title -}}
|
{{- $title := default $text .title -}}
|
||||||
{{- partial "render/link.html" (dict
|
{{- partial "render/link.html" (dict
|
||||||
@@ -11,5 +43,15 @@
|
|||||||
"Page" $page
|
"Page" $page
|
||||||
) -}}
|
) -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $addWikiLink }}
|
||||||
|
{{- $text := $wikiLink.name -}}
|
||||||
|
{{- $title := default $text $wikiLink.title -}}
|
||||||
|
{{- partial "render/link.html" (dict
|
||||||
|
"Destination" $wikiLink.url
|
||||||
|
"Title" $title
|
||||||
|
"Text" $text
|
||||||
|
"Page" $page
|
||||||
|
) -}}
|
||||||
|
{{- end }}
|
||||||
</nav>
|
</nav>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user