| | |
| | | import path from 'path' |
| | | import SlugAnchor from 'github-slugger' |
| | | |
| | | const slugAnchor = new SlugAnchor() |
| | | export const slugAnchor = new SlugAnchor() |
| | | |
| | | function slugSegment(s: string): string { |
| | | return s.replace(/\s/g, '-') |
| | |
| | | // resolve /a/b/c to ../../ |
| | | export function resolveToRoot(slug: string): string { |
| | | let fp = slug |
| | | if (fp.endsWith("/index")) { |
| | | fp = fp.slice(0, -"/index".length) |
| | | if (fp.endsWith("index")) { |
| | | fp = fp.slice(0, -"index".length) |
| | | } |
| | | |
| | | return fp |
| | | if (fp === "") { |
| | | return "." |
| | | } |
| | | |
| | | return "./" + fp |
| | | .split('/') |
| | | .filter(x => x !== '') |
| | | .map(_ => '..') |