aboutsummaryrefslogtreecommitdiff
path: root/public/main.js
diff options
context:
space:
mode:
authorJoris2023-01-21 14:10:47 +0100
committerJoris2023-01-21 14:10:47 +0100
commit25abf9bc7fd3e6f5b5aabf745cef7d217cde4262 (patch)
treed3ef6f2be1b117cfe5c75f5cd22408b2f47088f0 /public/main.js
parent424cabd49593b13470be1868cf75349b1830929c (diff)
Setup initial view of covers
Diffstat (limited to 'public/main.js')
-rw-r--r--public/main.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/public/main.js b/public/main.js
new file mode 100644
index 0000000..29de235
--- /dev/null
+++ b/public/main.js
@@ -0,0 +1,19 @@
+const sortedBooks = books.sort((a, b) =>
+ a.authorsSort == b.authorsSort
+ ? a.date > b.date
+ : a.authorsSort > b.authorsSort)
+
+const view = h('div',
+ { className: 'g-Books' },
+ ...sortedBooks.map(book => h('img', { className: 'g-Book', src: book.cover })))
+
+document.body.appendChild(view)
+
+// Helpers
+
+function h(tagName, attrs, ...children) {
+ let elem = document.createElement(tagName)
+ elem = Object.assign(elem, attrs)
+ for (const child of children) elem.append(child)
+ return elem
+}