-
Notifications
You must be signed in to change notification settings - Fork 5
/
render.js
45 lines (39 loc) · 1.58 KB
/
render.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const render = (columns) => {
const colors = options.COLOR_THEME;
const root = document.getElementById("container");
let colourIndex = 0;
root.innerHTML = columns
.filter((column) => column.children.length)
.map((column) => {
const listItems = column.children
.map((bookmark) => {
const title = trunc(
bookmark.path
.slice(1) // skip column name
.concat(bookmark.title) // add bookmark name
.join("/")
); // join as path
if (bookmark.isSeparator) {
return '<li class="separator"> </li>';
}
return `<li>
<a href="${bookmark.url}" ${
title.endsWith("…") ? `title="${bookmark.title}"` : ""
}>
${title}
</a>
</li>`;
})
.join("");
colourIndex =
colourIndex >= colors.length - 1 ? 0 : colourIndex + 1;
return `<div class="column">
<h2 class="folder-name" style="color: ${colors[colourIndex]}">
${column.title}
</h1>
<ul>${listItems}</ul>
</div>`;
})
.join("");
document.getElementById("welcome").innerHTML = options.TITLE;
};