-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.mjs
94 lines (58 loc) · 2.1 KB
/
gen.mjs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import fs from "fs";
import { page as eventPage } from "./events.mjs";
import { productPage, productListingPage } from "./products.mjs";
import { makerPage, makerListingPage } from "./makers.mjs";
import * as z from "./z.mjs";
import { getProducts, getEvents,getMakers } from "./db/coda.mjs";
import { page as resourcesPage } from "./resources.mjs"
import {formatKey} from "./common.mjs"
import { page as pocketSchoolPage } from "./pocket-startup-school.mjs"
const publicFolder = "./public/";
/*
Saveable page
{entity: "saveable",
state: {publicFolder, contents, title, location},
ts: {$init:
$save:
$genTitle: ({state: {publicFolder, title}}) => publicFolder + title;
}
fs.writeFileSync(publicFolder)
{
entity: "pages",
state: {pages: []},
ts: {$init,
$genlocations}
}
*/
const buildProductPage = async () => {
const products = await getProducts();
const productListing = productListingPage(products);
fs.writeFileSync(publicFolder + "index.html", productListing);
fs.writeFileSync(publicFolder + "products.html", productListing);
products.map(p => {
fs.writeFileSync(publicFolder + "product/" + p.id + ".html", productPage(p));
});
console.log("Generated products page");
};
const buildMakerPage = async () => {
const makers = await getMakers();
fs.writeFileSync(publicFolder + "makers.html", makerListingPage(makers));
for(let maker of makers) {
fs.writeFileSync(publicFolder + "makers/" + formatKey(maker.name) + ".html", makerPage(maker));
}
console.log("Generated makers page");
}
const buildEvents = async () => {
const events = await getEvents();
fs.writeFileSync(publicFolder + "events.html", eventPage(events));
console.log("Generated events page");
}
const buildResourcesPage = () => {
fs.writeFileSync(publicFolder + "resources.html", resourcesPage());
console.log("Generated resources page");
}
const buildPocketStartupSchoolPage = () => {
fs.writeFileSync(publicFolder + "resources/pocket-startup-school.html", pocketSchoolPage());
console.log("Generated Pocket Startup School page");
}
export { buildEvents, buildProductPage, buildMakerPage, buildResourcesPage, buildPocketStartupSchoolPage };