AP: fix object generation

This commit is contained in:
Shadowfacts 2019-02-18 13:53:35 -05:00
parent 8f73cd8106
commit 48368ae6e4
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 9 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import path from "path";
import { Page, PostMetadata } from "../metadata"; import { Page, PostMetadata } from "../metadata";
import * as util from "../util"; import * as util from "../util";
@ -6,7 +7,14 @@ const baseURL = process.env.BASE_URL || "shadowfacts.net";
export default async function activitypub(posts: Page[]) { export default async function activitypub(posts: Page[]) {
for (const post of posts) { for (const post of posts) {
const object = postObject(post); const object = postObject(post);
util.write(`ap/posts/${post.metadata.permalink}.json`, JSON.stringify(object)); const dir = path.dirname(post.metadata.permalink);
const base = path.basename(post.metadata.permalink);
const dest = path.format({
dir,
name: base,
ext: ".json"
});
util.write(dest, JSON.stringify(object));
} }
util.write("ap/actor", JSON.stringify(actorObject())) util.write("ap/actor", JSON.stringify(actorObject()))