From 441d31bb92048aa08aaba6d7c21040874f4f474f Mon Sep 17 00:00:00 2001 From: Richard Dern Date: Thu, 13 Nov 2025 00:02:21 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20liens=20wikip=C3=A9dia=20dans=20l?= =?UTF-8?q?es=20taxonomies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/42/assets/css/index.css | 2 +- themes/42/layouts/_partials/hero-section.html | 2 +- themes/42/layouts/_partials/page-links.html | 46 ++++++++++++++++++- themes/42/layouts/term.html | 2 +- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/themes/42/assets/css/index.css b/themes/42/assets/css/index.css index 700f6162..689d2a37 100644 --- a/themes/42/assets/css/index.css +++ b/themes/42/assets/css/index.css @@ -26,4 +26,4 @@ @import "table-of-contents.css"; @import "a.css"; @import "keywords.css"; -@import "aside.css"; \ No newline at end of file +@import "aside.css"; diff --git a/themes/42/layouts/_partials/hero-section.html b/themes/42/layouts/_partials/hero-section.html index 1a8941d1..6315c3eb 100644 --- a/themes/42/layouts/_partials/hero-section.html +++ b/themes/42/layouts/_partials/hero-section.html @@ -3,5 +3,5 @@
{{ partial "breadcrumbs.html" . }}
-

{{ .Title }}

+

{{ .Title }}

{{ partial "page-links.html" . }} \ No newline at end of file diff --git a/themes/42/layouts/_partials/page-links.html b/themes/42/layouts/_partials/page-links.html index fbe4cdba..1435b8f8 100644 --- a/themes/42/layouts/_partials/page-links.html +++ b/themes/42/layouts/_partials/page-links.html @@ -1,7 +1,39 @@ {{- $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 }} {{- end }} diff --git a/themes/42/layouts/term.html b/themes/42/layouts/term.html index 980555ea..c0fdcf39 100644 --- a/themes/42/layouts/term.html +++ b/themes/42/layouts/term.html @@ -5,4 +5,4 @@ {{- partial "articles-list.html" (dict "Pages" .Pages.ByDate.Reverse "Context" .) -}} -{{ end }} \ No newline at end of file +{{ end }}