hexo-theme-stellar/layout/_partial/widgets/components/linklist.ejs

27 lines
650 B
Plaintext
Raw Normal View History

2024-01-19 23:19:25 +08:00
<%
function layoutDiv(linklist) {
var links = linklist.items || []
if (links.length == 0) {
return ''
}
var el = ''
var style = ''
var columns = linklist.columns || links.length
if (links.length == 1) {
style += `style="grid-template-columns:repeat(1,1fr);"`
} else {
style += `style="grid-template-columns:repeat(${columns},1fr);"`
}
var align = 'center'
if (columns == 1 && links.length > 1) {
align = 'left'
}
el += `<div class="linklist ${align}" ${style}>`
for (let link of links) {
2024-01-20 13:35:43 +08:00
el += partial('link', {item: link, columns: columns})
2024-01-19 23:19:25 +08:00
}
el += `</div>`
return el
}
%>
<%- layoutDiv(item) %>