aboutsummaryrefslogtreecommitdiff
path: root/generator
diff options
context:
space:
mode:
Diffstat (limited to 'generator')
-rwxr-xr-x[-rw-r--r--]generator/main.js1
-rw-r--r--generator/postrenderer.js15
2 files changed, 12 insertions, 4 deletions
diff --git a/generator/main.js b/generator/main.js
index ccdc380..e25d5f2 100644..100755
--- a/generator/main.js
+++ b/generator/main.js
@@ -1,3 +1,4 @@
+#!/usr/bin/node
//Copyright Chris Xiong 2018
//License: Expat (MIT)
const content_dir='../content';
diff --git a/generator/postrenderer.js b/generator/postrenderer.js
index 8797c22..e387691 100644
--- a/generator/postrenderer.js
+++ b/generator/postrenderer.js
@@ -133,18 +133,25 @@ async function _render(inf,outf,np,pp)
await encrypt(trd);
//TOC
- const l=trd.getElementById('article').querySelectorAll('h2,h3,h4,h5,h6');
- const tocroot=trd.getElementById('tocroot');
tocid=0;
headerlist=[];
- for(let i of l)
- if(!i.classList.contains('notoc'))headerlist.push(i);
+ trd.getElementById('article').querySelectorAll('h2,h3,h4,h5,h6').forEach(
+ (i)=>{if(!i.classList.contains('notoc'))headerlist.push(i);}
+ );
+ const tocroot=trd.getElementById('tocroot');
for(let i=0;i<headerlist.length;)i=_dfs(trd,headerlist[i],tocroot,i);
if(!tocroot.children.length)trd.getElementById('tocouter').style.display='none';
//Footnotes
footnoter(trd);
+ //async images
+ //TODO: Actually compress the images using imagemagick
+ //(by introducing a new tag e.g. <thumb> ?)
+ trd.getElementById('article').querySelectorAll('img').forEach(
+ (i)=>{if(!i.getAttribute('decoding'))i.setAttribute('decoding','async');}
+ );
+
//Tag list
const tgs=meta[2].split(',');
for(let i=0;i<tgs.length;++i)