From 48368ae6e419533df1b02f880aee03b139a1a87d Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 18 Feb 2019 13:53:35 -0500 Subject: [PATCH] AP: fix object generation --- lib/generate/activitypub.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/generate/activitypub.ts b/lib/generate/activitypub.ts index 87a931a..57c9dcd 100644 --- a/lib/generate/activitypub.ts +++ b/lib/generate/activitypub.ts @@ -1,3 +1,4 @@ +import path from "path"; import { Page, PostMetadata } from "../metadata"; import * as util from "../util"; @@ -6,7 +7,14 @@ const baseURL = process.env.BASE_URL || "shadowfacts.net"; export default async function activitypub(posts: Page[]) { for (const post of posts) { 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()))