diff options
author | Chris Xiong <chirs241097@gmail.com> | 2024-08-11 22:15:43 -0400 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2024-08-11 22:15:43 -0400 |
commit | 7cd535517d3366f0a42b0f42d128537098af2a45 (patch) | |
tree | 66c9907ff2bcbeea11989db9c189aaabfa9efdca /generator | |
parent | abb10f112aa1248700e98caa0273f6afc5154a47 (diff) | |
download | sbs-master.tar.xz |
Diffstat (limited to 'generator')
-rwxr-xr-x | generator/main.js | 10 | ||||
-rw-r--r-- | generator/postrenderer.js | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/generator/main.js b/generator/main.js index 3697dbd..87c5885 100755 --- a/generator/main.js +++ b/generator/main.js @@ -45,24 +45,28 @@ function ensure_dir(p) const post_dir=path.join(config.dest_dir,'post'); ensure_dir(post_dir); +const prps=[]; for(let j=0;j<list.length;++j){ const i=list[j]; if(i.needsupdate||force) - postrenderer.render( + prps.push(postrenderer.render( path.join(config.content_dir,`${i.file}.txt`), path.join(post_dir,`${i.file}.html`), j?list[j-1].file:undefined, j<list.length-1?list[j+1].file:undefined ) .then((r)=>{console.log(`rendered: ${r}`);}) + .catch((e)=>{console.error(e);})); } const listrenderer=require('./listrenderer'); listrenderer.set_template(path.join(config.template_dir,'list_template')); list = list.filter((t) => (t.date.indexOf('UNLISTED') == -1)); -const gen_atom = require('./atomgen').gen_atom; -gen_atom(list, config); +Promise.all(prps).then((_) => { + const gen_atom = require('./atomgen').gen_atom; + gen_atom(list, config); +}); const list_dir=path.join(config.dest_dir,'list'); const ppp=config.posts_per_listpage; ensure_dir(list_dir); diff --git a/generator/postrenderer.js b/generator/postrenderer.js index 64cbb99..5a74d18 100644 --- a/generator/postrenderer.js +++ b/generator/postrenderer.js @@ -185,7 +185,7 @@ async function _render(inf,outf,np,pp) ); pp.stdin.end(); try { - trd.getElementById('article').innerHTML = await ppp; + trd.getElementById('article').innerHTML = await ppp; } catch (e) { console.log(`failed to render ${inf} : ${e}`); } |