Loading examples/blog/federation/mod.ts +16 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import { getFollowers, removeFollower, } from "../models/follower.ts"; import { countPosts, getPosts, toArticle } from "../models/post.ts"; import { countPosts, getPost, getPosts, toArticle } from "../models/post.ts"; import { openKv } from "../models/kv.ts"; import { getLogger } from "@logtape/logtape"; Loading Loading @@ -91,6 +91,21 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle, key) => { }; }); // Registers the object dispatcher, which is responsible for creating an // `Article` object for a given post UUID: federation.setObjectDispatcher( Article, "/posts/{uuid}", async (ctx, { uuid }) => { const blog = await getBlog(); if (blog == null) return null; const post = await getPost(uuid); if (post == null) return null; const comments = await getComments(post.uuid); return toArticle(ctx, blog, post, comments); }, ); // Registers the outbox dispatcher, which is responsible for listing // activities in the outbox: federation.setOutboxDispatcher( Loading examples/blog/routes/posts/[uuid].tsx +1 −6 Original line number Diff line number Diff line Loading @@ -24,17 +24,12 @@ export interface PostPageData { followers: bigint; } export const handler: Handler<PostPageData> = async (req, ctx) => { export const handler: Handler<PostPageData> = async (_req, ctx) => { const blog = await getBlog(); if (blog == null) return await ctx.renderNotFound(); const post = await getPost(ctx.params.uuid); if (post == null) return await ctx.renderNotFound(); const comments = await getComments(post.uuid); const fedCtx = federation.createContext(req); const article = toArticle(fedCtx, blog, post, comments); const response = await respondWithObjectIfAcceptable(article, req, fedCtx); if (response != null) return response; const followers = await countFollowers(); const data: PostPageData = { blog, Loading Loading
examples/blog/federation/mod.ts +16 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import { getFollowers, removeFollower, } from "../models/follower.ts"; import { countPosts, getPosts, toArticle } from "../models/post.ts"; import { countPosts, getPost, getPosts, toArticle } from "../models/post.ts"; import { openKv } from "../models/kv.ts"; import { getLogger } from "@logtape/logtape"; Loading Loading @@ -91,6 +91,21 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle, key) => { }; }); // Registers the object dispatcher, which is responsible for creating an // `Article` object for a given post UUID: federation.setObjectDispatcher( Article, "/posts/{uuid}", async (ctx, { uuid }) => { const blog = await getBlog(); if (blog == null) return null; const post = await getPost(uuid); if (post == null) return null; const comments = await getComments(post.uuid); return toArticle(ctx, blog, post, comments); }, ); // Registers the outbox dispatcher, which is responsible for listing // activities in the outbox: federation.setOutboxDispatcher( Loading
examples/blog/routes/posts/[uuid].tsx +1 −6 Original line number Diff line number Diff line Loading @@ -24,17 +24,12 @@ export interface PostPageData { followers: bigint; } export const handler: Handler<PostPageData> = async (req, ctx) => { export const handler: Handler<PostPageData> = async (_req, ctx) => { const blog = await getBlog(); if (blog == null) return await ctx.renderNotFound(); const post = await getPost(ctx.params.uuid); if (post == null) return await ctx.renderNotFound(); const comments = await getComments(post.uuid); const fedCtx = federation.createContext(req); const article = toArticle(fedCtx, blog, post, comments); const response = await respondWithObjectIfAcceptable(article, req, fedCtx); if (response != null) return response; const followers = await countFollowers(); const data: PostPageData = { blog, Loading