From edd8aa6e058d12dd0f9b0b886e507bd73dce72cb Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 9 Dec 2018 10:52:50 +0800 Subject: Load images asynchronously. Fix line endings in templates. Apply theme color. --- generator/main.js | 1 + generator/postrenderer.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) mode change 100644 => 100755 generator/main.js (limited to 'generator') diff --git a/generator/main.js b/generator/main.js old mode 100644 new mode 100755 index ccdc380..e25d5f2 --- 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 ?) + 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