]>
git.r.bdr.sh - rbdr/blog/blob - lib/generators/txt.js
dddcbafae55d87a7332ddac8a998425457b02946
4 import { readFile
, writeFile
} from 'fs/promises';
5 import { join
} from 'path';
6 import { debuglog
} from 'util';
9 debuglog: debuglog('blog'),
11 kTextName: 'index.txt'
15 * Generates a TXT version of the blog
18 * @param {string} source the source directory
19 * @param {string} target the target directory
20 * @param {Array.<Blog.tPost>} posts the list of posts
22 export default async
function TXTGenerator(source
, target
, posts
) {
24 internals
.debuglog('Generating TXT');
25 const textTarget
= join(target
, internals
.kTextName
);
26 const textLocation
= join(source
, internals
.kTextName
);
28 internals
.debuglog(`Reading ${textLocation}`);
29 const textTemplate
= await
readFile(textLocation
, { encoding: 'utf8' });
31 internals
.debuglog('Writing TXT');
32 const text
= Dot
.template(textTemplate
, {
33 ...Dot
.templateSettings
,
36 await
writeFile(textTarget
, text
);