MCPcopy Index your code
hub / github.com/simstudioai/sim / getRelatedPosts

Function getRelatedPosts

apps/sim/lib/blog/registry.ts:207–221  ·  view source on GitHub ↗
(slug: string, limit = 3)

Source from the content-addressed store, hash-verified

205}
206
207export async function getRelatedPosts(slug: string, limit = 3): Promise<BlogMeta[]> {
208 const posts = await getAllPostMeta()
209 const current = posts.find((p) => p.slug === slug)
210 if (!current) return []
211 const others = posts.filter((p) => p.slug !== slug)
212 const scored = others
213 .map((p) => ({
214 post: p,
215 score: p.tags.filter((t) => current.tags.includes(t)).length,
216 }))
217 .sort((a, b) => b.score - a.score || byDateDesc(a.post, b.post))
218 .slice(0, limit)
219 .map((x) => x.post)
220 return scored
221}

Callers 1

PageFunction · 0.90

Calls 2

byDateDescFunction · 0.90
getAllPostMetaFunction · 0.85

Tested by

no test coverage detected