2021-04-13 08:21:40 -05:00
|
|
|
<script>
|
|
|
|
function renderTags(tags) {
|
2021-04-19 04:47:00 -05:00
|
|
|
if (tags.length <= 0) return '';
|
2021-07-07 07:33:45 -05:00
|
|
|
let res = `| <span title='{{ i18n "tags" | safeJS }}'> </span>`;
|
2021-04-19 04:47:00 -05:00
|
|
|
for (let tag of tags) {
|
2021-07-07 07:33:45 -05:00
|
|
|
// regular space
|
|
|
|
res += `<a href="/tags/${tag}">#${tag}</a> `;
|
2021-04-19 04:47:00 -05:00
|
|
|
}
|
|
|
|
return res;
|
2021-04-13 08:21:40 -05:00
|
|
|
}
|
2022-03-10 03:36:40 -06:00
|
|
|
function renderImage(image, link) {
|
2021-04-13 08:21:40 -05:00
|
|
|
if (!image) return '';
|
2022-03-10 03:36:40 -06:00
|
|
|
return `<a href="${link}"><img src="${image}" /></a>`;
|
2021-04-13 08:21:40 -05:00
|
|
|
}
|
|
|
|
function renderSingleArticle(article) {
|
|
|
|
return `
|
2021-12-28 03:46:29 -06:00
|
|
|
<article class="card postlistitem">
|
2021-04-13 08:21:40 -05:00
|
|
|
<div>
|
|
|
|
<h2>
|
2021-06-16 04:08:07 -05:00
|
|
|
<a href="${article.link}">${article.title}</a>
|
2021-04-13 08:21:40 -05:00
|
|
|
</h2>
|
|
|
|
<p class="date">
|
2022-03-10 03:36:40 -06:00
|
|
|
<span title='{{ i18n "date" | safeJS }}'> </span>
|
|
|
|
${article.date}
|
|
|
|
{{ if (.Site.Params.tagsInArticlePreview | default true) }}
|
|
|
|
${renderTags(article.tags)}
|
|
|
|
{{ end }}
|
2021-04-13 08:21:40 -05:00
|
|
|
</p>
|
|
|
|
{{ if .Site.Params.imageInArticlePreview }}
|
2022-03-10 03:36:40 -06:00
|
|
|
${renderImage(article.image, article.link)}
|
|
|
|
{{ end }}
|
2021-06-16 04:08:07 -05:00
|
|
|
{{ if (site.Params.articleSummary | default true) }}
|
|
|
|
<div class="articlePreview">
|
|
|
|
<p>${article.summary}</p>
|
2021-07-07 07:33:45 -05:00
|
|
|
<p><a href="${article.link}">{{ i18n "continueReading" | safeJS }} </a></p>
|
2021-06-16 04:08:07 -05:00
|
|
|
</div>
|
|
|
|
{{ end }}
|
2021-04-13 08:21:40 -05:00
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
</article>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
function renderArticles(articles) {
|
|
|
|
let rendered = articles.map(a => renderSingleArticle(a)).join('\n');
|
|
|
|
document.getElementById('postlist').innerHTML += rendered;
|
|
|
|
}
|
|
|
|
</script>
|