+ const posts = await this._readPosts();
+
+ 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);
+
+ await GemlogArchiver(this.archiveDirectory);
+ }
+
+ // Reads the posts into an array
+
+ async _readPosts() {
+
+ internals.debuglog('Reading posts');
+ const posts = [];
+
+ for (let i = 0; i < this.maxPosts; ++i) {
+ try {
+ posts.push(await this._readPost(i));
+ }
+ catch (error) {
+ if (error.code === kFileNotFoundError) {
+ internals.debuglog(`Skipping ${i}`);
+ continue;
+ }
+
+ throw error;
+ }
+ }
+
+ return posts;
+ }
+
+ // Reads an individual post
+
+ async _readPost(index=0) {
+ const postSourcePath = join(this.postsDirectory, `${index}`);
+
+ internals.debuglog(`Reading ${postSourcePath}`);
+
+ await access(postSourcePath);
+
+ const metadata = await this._getMetadata(index);
+
+ const postContentPath = await this._findBlogContent(postSourcePath);
+ internals.debuglog(`Reading ${postContentPath}`);
+ const postContent = await readFile(postContentPath, { encoding: 'utf8' });
+
+ internals.debuglog('Parsing Gemini');
+ return {
+ ...metadata,
+ location: postSourcePath,
+ index,
+ html: RenderGemini(ParseGemini(postContent)),
+ raw: postContent
+ };