UNPKG

@braindb/core

Version:

markdown-graph-content-layer-database

21 lines (20 loc) 795 B
import { basename } from "node:path"; export const defaultGetUrl = (filePath, _frontmatter) => { let url = filePath.replace(/\/_?index\.mdx?$/, "").replace(/\.mdx?$/, "") || "/"; // if (!url.startsWith("/")) url = "/" + url; if (!url.endsWith("/")) url = url + "/"; return url; }; // Hugo style // export const getSlug = (filePath: string, frontmatter: Frontmatter) => { // let slug: string; // if (frontmatter.slug) { // // no validation - trusting source // slug = String(frontmatter.slug); // } else { // slug = basename(filePath.replace(/\/_?index\.mdx?$/, "")).replace(/\.mdx?$/, "") || "/" // } // }; export const defaultGetSlug = (filePath, _frontmatter) => basename(filePath.replace(/\/_?index\.mdx?$/, "")).replace(/\.mdx?$/, "") || "/";