+ // Writes metadata. Assumes post 0 since it only gets written
+ // on create
+
+ async _writeMetadata(metadata) {
+
+ const metadataTarget = join(this.postsDirectory, '0', internals.kMetadataFilename);
+ internals.debuglog(`Writing ${metadataTarget}`);
+ await writeFile(metadataTarget, JSON.stringify(metadata, null, 2));
+ }
+
+ // Copies a post directory to the latest slot.
+
+ async _copyPost(postLocation) {
+
+ const targetPath = join(this.postsDirectory, '0');
+ const postName = basename(postLocation);
+ const targetPost = join(targetPath, postName);
+
+ internals.debuglog(`Removing ${targetPath}`);
+ await rmIfExists(targetPath);
+ await ensureDirectoryExists(targetPath);
+ internals.debuglog(`Adding ${postLocation} to ${targetPost}`);
+ await cp(postLocation, targetPost, { recursive: true });
+ internals.debuglog(`Added ${postLocation} to ${targetPath}`);
+ }
+
+ // Looks for a `.gmi` file in the blog directory, and returns the path