## Unreleased
### Added
- Post Metadata support
-- RSS Support
+- RSS support
+- TXT support
### Changed
- Updated dependencies
const StaticGenerator = require('./generators/static');
const HTMLGenerator = require('./generators/html');
const RSSGenerator = require('./generators/rss');
+const TXTGenerator = require('./generators/txt');
const internals = {
await StaticGenerator(this.postsDirectory, this.staticDirectory, posts);
await HTMLGenerator(this.templatesDirectory, this.staticDirectory, posts);
await RSSGenerator(this.templatesDirectory, this.staticDirectory, posts);
+ await TXTGenerator(this.templatesDirectory, this.staticDirectory, posts);
}
// Reads the posts into an array
internals.debuglog('Parsing markdown');
posts.push({
...metadata,
- html: Marked(postContent)
+ html: Marked(postContent),
+ raw: postContent
});
}
catch (error) {
--- /dev/null
+'use strict';
+
+const { template, templateSettings } = require('dot');
+const { readFile, writeFile } = require('fs/promises');
+const { join } = require('path');
+const { debuglog } = require('util');
+
+const internals = {
+ debuglog: debuglog('blog'),
+
+ kTextName: 'index.txt'
+};
+
+/**
+ * Generates a TXT version of the blog
+ *
+ * @name TXTGenerator
+ * @param {string} source the source directory
+ * @param {string} target the target directory
+ * @param {Array.<Blog.tPost>} posts the list of posts
+ */
+module.exports = async function TXTGenerator(source, target, posts) {
+
+ internals.debuglog('Generating TXT');
+ const textTarget = join(target, internals.kTextName);
+ const textLocation = join(source, internals.kTextName);
+
+ internals.debuglog(`Reading ${textLocation}`);
+ const textTemplate = await readFile(textLocation, { encoding: 'utf8' });
+
+ internals.debuglog('Writing TXT');
+ const text = template(textTemplate, {
+ ...templateSettings,
+ strip: false
+ })({ posts });
+ await writeFile(textTarget, text);
+};
+
--- /dev/null
+╔══════════════════════════════════════════════════════════════════════════════╗
+║ ║
+║ The Blog at Unlimited Pizza ║
+║ ║
+╚══════════════════════════════════════════════════════════════════════════════╝
+┌──────────────────────────────────────────────────────────────────────────────┐
+│ Written by Rubén Beltrán del Río │
+└──────────────────────────────────────────────────────────────────────────────┘
+
+{{~ it.posts: post}}
+{{= post.raw}}
+■──────────────────────────────────────────────────────────────────────────────■
+{{~}}
+{{? it.posts.length === 0}}
+# This is a fresh blog!
+
+There are no posts yet.
+{{?}}