throw err
return false
}
- let out = []
- await jst(env, out)
- this.serve(env, Buffer.from(out.join('')), 'jst')
+ await jst(env)
return true
}
Site.prototype.respond = async function(env) {
while (true) {
if (env.pathname_pos >= env.pathname.length) {
+ // directory without trailing slash
this.redirect(env, env.pathname + '/index.html')
return
}
if (filename.length === 0) {
if (j >= env.pathname.length)
+ // directory with trailing slash
this.redirect(env, env.pathname + 'index.html')
else
this.die(env, `empty directory name in ${env.pathname}`)
-return async (_env, _out) => {
- html {
- head {
- link(rel="stylesheet" type="text/css" href="css/styles.css") {}
- }
- body {
- p {'Hello, world'}
- }
- }
+return async env => {
+ env.site.serve(
+ env,
+ Buffer.from(
+ html {
+ head {
+ link(rel="stylesheet" type="text/css" href="css/styles.css") {}
+ }
+ body {
+ p {'Hello, world'}
+ }
+ }
+ ),
+ 'index.jst'
+ )
}