Add blog post object
This commit is contained in:
parent
dada521fba
commit
41e4a9475e
1 changed files with 17 additions and 0 deletions
17
javascript/BlogPost.js
Normal file
17
javascript/BlogPost.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import element from 'https://cdn.jsdelivr.net/gh/darkwiiplayer/js@3724b3e/element.js'
|
||||||
|
import {html, empty} from 'https://cdn.jsdelivr.net/gh/darkwiiplayer/js@cdaeac1/skooma.js'
|
||||||
|
|
||||||
|
export default element(class BlogPost extends HTMLElement {
|
||||||
|
static attributes = { name: true }
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.post = posts.find(post => post.head.slug == this.name)
|
||||||
|
}
|
||||||
|
async nameChanged() {
|
||||||
|
this.replace(
|
||||||
|
html.a({href: `/blog${this.post.head.uri}`}, html.h2(this.post.head.title)),
|
||||||
|
this.post.head.description ? html.p(this.post.head.description) : undefined,
|
||||||
|
html.p(html.time$localDate({datetime: this.post.head.date, class: ["timestamp"]}))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in a new issue