UNPKG

@studiocms/blog

Version:

Add a blog to your StudioCMS project with ease!

21 lines (20 loc) 713 B
import blogConfig from "studiocms:blog/config"; import { pathWithBase } from "studiocms:lib"; import { dual } from "studiocms/effect"; const blogRouteFullPath = `${blogConfig.route}/[...slug]`; function getBlogRoute(slug) { return blogRouteFullPath.replace("[...slug]", slug); } const remapFilterSitemap = dual(4, (array, filter, context, blog = false) => { function genLocation(slug) { const newPath = blog ? getBlogRoute(slug) : slug; return new URL(pathWithBase(newPath), context.url); } return array.map(({ data }) => data).filter(({ package: pkg }) => pkg === filter).map(({ slug }) => ({ location: genLocation(slug).toString() })); }); export { getBlogRoute, remapFilterSitemap };