]>
git.r.bdr.sh - rbdr/blog/blob - lib/generators/txt.js
c3d777806f85b56520dc77fa7920f9153420ff39
2 import { readFile
, writeFile
} from 'fs/promises';
3 import { join
} from 'path';
4 import { debuglog
} from 'util';
7 debuglog: debuglog('blog'),
13 * Generates a TXT version of the blog
16 * @param {string} source the source directory
17 * @param {string} target the target directory
18 * @param {Array.<Blog.tPost>} posts the list of posts
20 export default async
function TXTGenerator(source
, target
, posts
) {
22 internals
.debuglog('Generating TXT');
23 const textTarget
= join(target
, internals
.kTextName
);
24 const textLocation
= join(source
, internals
.kTextName
);
26 internals
.debuglog(`Reading ${textLocation}`);
27 const textTemplate
= await
readFile(textLocation
, { encoding: 'utf8' });
29 internals
.debuglog('Writing TXT');
30 const text
= Dot
.template(textTemplate
, {
31 ...Dot
.templateSettings
,
34 await
writeFile(textTarget
, text
);