This repository was archived by the owner on Sep 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
79 lines (66 loc) · 1.92 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
67
68
69
70
71
72
73
74
75
76
77
78
79
const choo = require('choo')
const css = require('sheetify')
const sw = require('./plugins/choo-sw')
const ssr = require('choo-ssr')
const data = require('choo-data')
const async = require('choo-async')
const bundles = require('choo-bundles')
const devtools = require('choo-devtools')
const html = require('./views/components/html')
const layout = require('./views/components/layout')
const noscript = require('./views/components/noscript')
const head = require('./views/components/head')
const error = require('./views/error')
const ask = require('./views/ask')
const show = require('./views/show')
const jobs = require('./views/jobs')
const home = require('./views/home')
const newest = require('./views/newest')
const comments = require('./views/comments')
css('./index.css')
function main () {
const app = async(choo())
app.use(sw())
app.use(ssr())
app.use(data())
app.use(bundles())
if (process.env.NODE_ENV !== 'production') {
app.use(devtools())
}
const page = content => (
html(
ssr.head(
head(),
// bundles.preloads(),
bundles.assets()
),
ssr.body(
async.catch(
layout(content),
error()
),
noscript(),
ssr.state(),
)
)
)
app.route('/', page(home(app)))
app.route('/page/:page', page(home(app)))
app.route('/newest', page(newest(app)))
app.route('/newest/page/:page', page(newest(app)))
app.route('/newcomments', page(comments(app)))
app.route('/newcomments/page/:page', page(comments(app)))
app.route('/show', page(show(app)))
app.route('/show/page/:page', page(show(app)))
app.route('/ask', page(ask(app)))
app.route('/ask/page/:page', page(ask(app)))
app.route('/jobs', page(jobs(app)))
app.route('/jobs/page/:page', page(jobs(app)))
app.route('/app-shell', page(() => {}))
return app
}
if (typeof window !== 'undefined') {
const app = main()
app.mount('html')
}
module.exports = main