| | |
| | | import path from 'path' |
| | | import SlugAnchor from 'github-slugger' |
| | | |
| | | export const slugAnchor = new SlugAnchor() |
| | | import { slug as slugAnchor } from 'github-slugger' |
| | | |
| | | function slugSegment(s: string): string { |
| | | return s.replace(/\s/g, '-') |
| | |
| | | |
| | | export function slugify(s: string): string { |
| | | const [fp, anchor] = s.split("#", 2) |
| | | const sluggedAnchor = anchor === undefined ? "" : "#" + slugAnchor.slug(anchor) |
| | | const sluggedAnchor = anchor === undefined ? "" : "#" + slugAnchor(anchor) |
| | | const withoutFileExt = fp.replace(new RegExp(path.extname(fp) + '$'), '') |
| | | const rawSlugSegments = withoutFileExt.split(path.sep) |
| | | const slugParts: string = rawSlugSegments |