+ /**
+ * Pulls the posts and archive from the remote
+ *
+ * @function syncDown
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async syncDown() {
+
+ internals.debuglog('Pulling remote state');
+ await ensureDirectoryExists(this.dataDirectory);
+ await Remote.syncDown(this.remoteConfig, this.dataDirectory);
+ internals.debuglog('Pulled remote state');
+ }
+
+ /**
+ * Pushes the posts and archive to the remote
+ *
+ * @function syncUp
+ * @memberof Blog
+ * @return {Promise<undefined>} empty promise, returns no value
+ * @instance
+ */
+ async syncUp() {
+
+ internals.debuglog('Pushing remote state');
+ await ensureDirectoryExists(this.dataDirectory);
+ await Remote.syncUp(this.remoteConfig, this.dataDirectory);
+ internals.debuglog('Pushed remote state');
+ }
+
+ // Adds the passed path to slot 0, and generates files.
+
+ async _update(postLocation) {
+
+ const metadata = await this._getMetadata();
+ await ensureDirectoryExists(this.postsDirectory);
+ await this._copyPost(postLocation);
+ await this._writeMetadata(metadata);
+
+ await this._archive(postLocation);
+
+ await this.generate();
+ try {
+ await this.syncUp();
+ }
+ catch {}
+ }
+
+
+ // Parses Gemini for each page, copies assets and generates index.
+
+ async generate() {
+
+ internals.debuglog('Generating output');
+
+ const posts = await this._readPosts();
+
+ // Start from a clean slate.
+ await rmIfExists(this.blogOutputDirectory);
+ await ensureDirectoryExists(this.blogOutputDirectory);
+
+ // Run each generator
+ await StaticGenerator(this.staticDirectory, this.blogOutputDirectory, posts);
+ await HTMLGenerator(await this._templateDirectoryFor('index.html'), this.blogOutputDirectory, posts);
+ await RSSGenerator(await this._templateDirectoryFor('feed.xml'), this.blogOutputDirectory, posts);
+ await TXTGenerator(await this._templateDirectoryFor('index.txt'), this.blogOutputDirectory, posts);
+
+ // Start from a clean slate.
+ await rmIfExists(this.archiveOutputDirectory);
+ await ensureDirectoryExists(this.archiveOutputDirectory);
+ await ensureDirectoryExists(this.archiveDirectory);
+
+ // Run each archiver
+ await GemlogArchiver(await this._templateDirectoryFor('index.gmi'), this.archiveDirectory, this.archiveOutputDirectory);
+ // TODO: GopherArchiver
+ }
+
+ // 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));