From abb10f112aa1248700e98caa0273f6afc5154a47 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 22 Jun 2024 20:07:43 -0400 Subject: Yes we are 2.6 now. --- generator/main.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'generator/main.js') diff --git a/generator/main.js b/generator/main.js index ce6c8ff..3697dbd 100755 --- a/generator/main.js +++ b/generator/main.js @@ -1,22 +1,33 @@ #!/usr/bin/node //Copyright Chris Xiong 2018 //License: Expat (MIT) -const content_dir='../content'; -const template_dir='../templates'; -const dest_dir='../generated'; -const posts_per_listpage=5; +const config = { + content_dir: '../content', + template_dir: '../templates', + dest_dir: '../generated', + posts_per_listpage: 5, + // These are only used by the Atom feed generator + atom_feed_nposts: 10, + version_string: '2.6', + atom_url: 'https://chrisoft.org/blog/atom.xml', + published_url: 'https://chrisoft.org/blog/', + atom_title: 'Specluncam Ursae', + atom_subtitle: 'Chris Xiong\'s blog posts', + atom_author: 'Chris Xiong', + atom_icon: 'https://chrisoft.org/cx.png' +}; const fs=require('fs'); const path=require('path'); const scanner=require('./scanner'); -let list=scanner.scan(content_dir,dest_dir); +let list=scanner.scan(config.content_dir,config.dest_dir); const tags=scanner.build_list_index(); const taglist=Object.keys(tags).sort(); const force=process.argv.indexOf('--force')!=-1; const postrenderer=require('./postrenderer'); -postrenderer.set_template(path.join(template_dir,'post_template')); +postrenderer.set_template(path.join(config.template_dir,'post_template')); function ensure_dir(p) { @@ -32,13 +43,13 @@ function ensure_dir(p) if(!fs.statSync(p).isDirectory())throw 'shit'; } -const post_dir=path.join(dest_dir,'post'); +const post_dir=path.join(config.dest_dir,'post'); ensure_dir(post_dir); for(let j=0;j (t.date.indexOf('UNLISTED') == -1)); -const list_dir=path.join(dest_dir,'list'); -const ppp=posts_per_listpage; +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); let pc=Math.floor(list.length/ppp)+(list.length%ppp!=0); for(let i=0;i