-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridsearch.js
43 lines (42 loc) · 1.14 KB
/
gridsearch.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
fetch("/sketches.json")
.then((response) => response.json())
.then((data) => createTable(data));
function createTable(sketches) {
new gridjs.Grid({
sort: true,
columns: [
{
id: "sketch",
name: "Sketch",
formatter: (_, row) =>
gridjs.html(
`<a class='capitalize' href='/${
row.cells[0].data
}/'>${row.cells[0].data.replace("-", " ")}</a>`
),
},
{
id: "createdDate",
name: "Created Date",
formatter: (cell) =>
`${new Intl.DateTimeFormat("en-US").format(new Date(cell))}`,
},
{
name: "Last Modified Date",
id: "lastModifiedDate",
formatter: (cell) =>
`${new Intl.DateTimeFormat("en-US").format(new Date(cell))}`,
},
{
id: "code",
name: "Code",
formatter: (_, row) =>
gridjs.html(
`<a class='capitalize' href='https://github.com/jkenzer/jkenzer.github.io/tree/master/${row.cells[0].data}/'>Code</a>`
),
},
],
search: true,
data: sketches,
}).render(document.getElementById("wrapper"));
}