From 3706ace5e8cce91b291875e8a8563321343b92d5 Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 24 Oct 2022 08:16:12 +0200 Subject: [PATCH] use image alt wherever possible --- layouts/_default/search.json | 3 ++- layouts/index.json | 3 ++- layouts/partials/article_card.html | 4 ++-- layouts/partials/js_paginator.html | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/layouts/_default/search.json b/layouts/_default/search.json index b374521..19d17f2 100644 --- a/layouts/_default/search.json +++ b/layouts/_default/search.json @@ -19,7 +19,8 @@ "summary" (or .Params.description .Summary) "text" (lower .Plain) "link" .Permalink - "image" $image) }} + "image" $image + "imageAlt" (or .Params.Alt "")) }} {{ end }} "pages": {{ $mscratch.Get "articles" | jsonify }} } diff --git a/layouts/index.json b/layouts/index.json index 1d17dd4..5ff5066 100644 --- a/layouts/index.json +++ b/layouts/index.json @@ -25,7 +25,8 @@ "tags" (sort (or .Params.tags slice)) "summary" (or .Params.description .Summary) "link" .Permalink - "image" $image) }} + "image" $image + "imageAlt" (or .Params.Alt "")) }} {{ end }} "articles": {{ $mscratch.Get "articles" | jsonify }}, "test": "{{range $postsList}}{{.Title}} {{end}}", diff --git a/layouts/partials/article_card.html b/layouts/partials/article_card.html index 62c11bf..9e899d7 100644 --- a/layouts/partials/article_card.html +++ b/layouts/partials/article_card.html @@ -18,9 +18,9 @@ {{ if .Params.Image }} {{ if or (hasPrefix .Params.Image "/") (hasPrefix .Params.Image "http://") (hasPrefix .Params.Image "https://") }} - + {{ .Params.Alt }} {{ else }} - + {{ .Params.Alt }} {{ end }} {{ end }} diff --git a/layouts/partials/js_paginator.html b/layouts/partials/js_paginator.html index 81dfda4..3371f2d 100644 --- a/layouts/partials/js_paginator.html +++ b/layouts/partials/js_paginator.html @@ -8,9 +8,9 @@ } return res; } - function renderImage(image, link) { + function renderImage(image, link, alt) { if (!image) return ''; - return ``; + return `${alt}`; } function renderSingleArticle(article) { return ` @@ -27,7 +27,7 @@ {{ end }}

{{ if .Site.Params.imageInArticlePreview }} - ${renderImage(article.image, article.link)} + ${renderImage(article.image, article.link, article.imageAlt)} {{ end }} {{ if (site.Params.articleSummary | default true) }}