paginate infinite nightmare with json data

This commit is contained in:
jonathan
2023-10-11 17:27:45 +10:30
parent a7c5acc1a2
commit 37a310888a
3 changed files with 221 additions and 223 deletions

View File

@ -18,7 +18,7 @@ module.exports = function (eleventyConfig) {
.trim()
// remove accents
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[\u0300-\u036f]/g, '')
// replace invalid characters with spaces
.replace(/[^a-z0-9\s-]/g, ' ')
.trim()
@ -34,6 +34,37 @@ module.exports = function (eleventyConfig) {
</div>`
});
eleventyConfig.addShortcode("infinitenightmare", function (title, link, image, video, description) {
if (!title || title == "") {
return '';
};
return `<hr>
<p>
<strong>${title}</strong><br>
${// evil nested tertiary this is the worlds least oneline oneliner
!link || link == "" ?
"" :
Array.isArray(link) ?
(typeof link[0] === 'string' ?
link.map((l) => `<a href="${l}">link</a><br>`).join(" // ") + '<br>' :
link.map((l) => `<a href="${l.link}">${l.title}</a>`).join(" // ") + '<br>') :
`<a href="${link}">link</a><br>`
}${!image || image == "" ?
"" :
Array.isArray(image) ?
image.map((i) => `<img src="${i}"></img><br>`).join(" ") :
`<img src="${image}"></img><br>`
}${!video || video == "" ?
"" :
`<video autoplay loop muted controls poster="${video.poster}">
<source src="${video.link}" type="video/mp4"></source>
<img src="${video.poster}"></img>
</video><br>`
}${description}
</p>`
});
// make a list of all tags besides "post" and add them to the collection
eleventyConfig.addCollection("tagsList", function (collectionApi) {
const tagsList = new Set();