-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (52 loc) · 2.18 KB
/
index.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { createComponent } from 'bloql/PostList';
class PostList extends Component {
onButtonClick(filters) {
// Dynamically loads a different set of articles depending on filters
this.props.bloql.setFilters(filters);
}
onResetButtonClick(filters) {
// Reset all filters
this.props.bloql.resetFilters();
}
render() {
// Render your post list using all react components you want
return (
<div>
<div>
<button onClick={this.onResetButtonClick.bind(this)}>Reset All</button>
</div>
<div>
Tag filters:
<button onClick={this.onButtonClick.bind(this, {tags: null})}>Reset tags</button>
<button onClick={this.onButtonClick.bind(this, {tags: ['film']})}>Films</button>
<button onClick={this.onButtonClick.bind(this, {tags: ['film', 'france']})}>French films</button>
<button onClick={this.onButtonClick.bind(this, {tags: ['town']})}>Towns</button>
<button onClick={this.onButtonClick.bind(this, {tags: ['france']})}>France</button>
<button onClick={this.onButtonClick.bind(this, {tags: ['poland']})}>Poland</button>
</div>
<div>
Date filters:
<button onClick={this.onButtonClick.bind(this, {endDate: null, startDate: null})}>Reset date</button>
<button onClick={this.onButtonClick.bind(this, {endDate: '2015-01-01', startDate: null})}>Articles before 01/01/2015</button>
<button onClick={this.onButtonClick.bind(this, {endDate: null, startDate: '2015-01-01'})}>Articles after 01/01/2015</button>
<button onClick={this.onButtonClick.bind(this, {endDate: '2015-05-31', startDate: '2015-05-01'})}>Articles in May 2015</button>
</div>
<ul>
{this.props.bloql.posts.map(post =>
<li key={post.meta.slug}>
<a href={'/post.html#' + post.meta.slug}>{post.meta.title}</a>
</li>
)}
</ul>
</div>
);
}
}
// Convert your component into a Bloql element
PostList = createComponent(PostList);
ReactDOM.render(
<PostList/>,
document.getElementById('app')
);