+ // 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 file to the latest slot.
+
+ async _copyPost(postLocation) {
+
+ internals.debuglog(`Copying ${postLocation}`);
+ const targetPath = join(this.postsDirectory, '0');
+ const postName = basename(postLocation);
+ const targetPost = join(targetPath, postName);
+
+ await rmIfExists(targetPath);
+ await ensureDirectoryExists(targetPath);
+ 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