'use strict';
-const { template } = require('dot');
+const { template, templateSettings } = require('dot');
const { readFile, writeFile } = require('fs/promises');
const { join } = require('path');
const { debuglog } = require('util');
const indexTemplate = await readFile(indexLocation, { encoding: 'utf8' });
internals.debuglog('Writing HTML');
- const indexHtml = template(indexTemplate)({ posts });
+ const indexHtml = template(indexTemplate, {
+ ...templateSettings,
+ strip: false
+ })({ posts });
await writeFile(indexTarget, indexHtml);
};
'use strict';
-const { template } = require('dot');
+const { template, templateSettings } = require('dot');
const { encodeXML } = require('entities');
const { readFile, writeFile } = require('fs/promises');
const { join } = require('path');
const internals = {
debuglog: debuglog('blog'),
- kFeedName: 'feed.xml'
+ kFeedName: 'feed.xml',
+
+ extractTitle(postText) {
+
+ return postText.trim().split('\n')[0].replace('#', '').trim();
+ }
};
/**
posts = posts.map((post) => ({
...post,
createdOn: (new Date(post.createdOn)).toUTCString(),
+ title: internals.extractTitle(post.raw),
html: encodeXML(post.html)
}));
- const feedXml = template(feedTemplate)({ posts });
+ const feedXml = template(feedTemplate, {
+ ...templateSettings,
+ strip: false
+ })({ posts });
await writeFile(feedTarget, feedXml);
};
-
-