article image click links to article

This commit is contained in:
Gabriele Musco 2022-03-10 10:36:40 +01:00
parent 92861a3b56
commit 5de16a03ce
No known key found for this signature in database
GPG Key ID: 0587A5D65B5DC99E
2 changed files with 12 additions and 10 deletions

View File

@ -16,7 +16,9 @@
</p>
{{ if .Site.Params.imageInArticlePreview }}
{{ if .Params.Image }}
<img src="{{ .Params.Image }}" />
<a class="unstyledLink" href="{{ .Permalink }}">
<img src="{{ .Params.Image }}" />
</a>
{{ end }}
{{end}}
{{ if (site.Params.articleSummary | default true) }}

View File

@ -8,9 +8,9 @@
}
return res;
}
function renderImage(image) {
function renderImage(image, link) {
if (!image) return '';
return `<img src="${image}" />`
return `<a href="${link}"><img src="${image}" /></a>`;
}
function renderSingleArticle(article) {
return `
@ -20,15 +20,15 @@
<a href="${article.link}">${article.title}</a>
</h2>
<p class="date">
<span title='{{ i18n "date" | safeJS }}'></span>
${article.date}
{{ if (.Site.Params.tagsInArticlePreview | default true) }}
${renderTags(article.tags)}
{{ end }}
<span title='{{ i18n "date" | safeJS }}'></span>
${article.date}
{{ if (.Site.Params.tagsInArticlePreview | default true) }}
${renderTags(article.tags)}
{{ end }}
</p>
{{ if .Site.Params.imageInArticlePreview }}
${renderImage(article.image)}
{{end}}
${renderImage(article.image, article.link)}
{{ end }}
{{ if (site.Params.articleSummary | default true) }}
<div class="articlePreview">
<p>${article.summary}</p>