[www] Article updated, added rendering of article tags

This commit is contained in:
Roman Timashev committed 2017-10-28 15:51:50 +03:00
1 parent b4337eec52
commit 1f45596dd3
5 files changed
+70 -9

No files matched your search

+11 -1
View File
@@ -5,6 +5,10 @@ const {find, findOne, total} = require('../lib/store')
const store = () => Data.getStore(Article)
function make(C) {
return x => new C(x)
}
class Article {
static async find(query, options = {}) {
const items = await find(store(), query, options)
@@ -41,7 +45,7 @@ class Article {
this.date = data.date
this.title = data.title
this.until = data.until
this.tags = data.tags
this.tags = (data.tags || []).map(make(Tag))
this.content = data.content
this.hash = data.hash
this.type = data.type
@@ -75,6 +79,12 @@ class Article {
}
}
class Tag {
constructor(tag) {
this.name = tag;
}
}
const previewFromImage = (imgs = []) => imgs.length
? imgs[0]
: null