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 '';
|
|
|
|
let res = '| <span title="tags"> </span>';
|
|
|
|
for (let tag of tags) {
|
|
|
|
res += `<a href="/tags/${tag}">#${tag}</a>`;
|
|
|
|
}
|
|
|
|
return res;
|
2021-04-13 08:21:40 -05:00
|
|
|
}
|
|
|
|
function renderImage(image) {
|
|
|
|
if (!image) return '';
|
|
|
|
return `<img src="${image}" />`
|
|
|
|
}
|
|
|
|
function renderSingleArticle(article) {
|
|
|
|
return `
|
|
|
|
<article class="card postlistitem {{ if .Site.Params.discreteCards }}discrete{{ end }}">
|
|
|
|
<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">
|
|
|
|
<span title="Date"> </span>
|
|
|
|
${article.date}
|
2021-04-19 04:42:35 -05:00
|
|
|
{{ if (.Site.Params.tagsInArticlePreview | default true) }}
|
|
|
|
${renderTags(article.tags)}
|
|
|
|
{{ end }}
|
2021-04-13 08:21:40 -05:00
|
|
|
</p>
|
|
|
|
{{ if .Site.Params.imageInArticlePreview }}
|
|
|
|
${renderImage(article.image)}
|
|
|
|
{{end}}
|
2021-06-16 04:08:07 -05:00
|
|
|
{{ if (site.Params.articleSummary | default true) }}
|
|
|
|
<div class="articlePreview">
|
|
|
|
<p>${article.summary}</p>
|
|
|
|
<p><a href="${article.link}">Continue reading </a></p>
|
|
|
|
</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>
|