| | |
| | | import { QuartzTransformerPlugin } from "../types" |
| | | import { clientSideSlug, relativeToRoot, slugify, trimPathSuffix } from "../../path" |
| | | import { clientSideSlug, relative, relativeToRoot, slugify, trimPathSuffix } from "../../path" |
| | | import path from "path" |
| | | import { visit } from 'unist-util-visit' |
| | | import isAbsoluteUrl from "is-absolute-url" |
| | | |
| | | interface Options { |
| | | /** How to resolve Markdown paths */ |
| | | markdownLinkResolution: 'absolute' | 'relative' |
| | | markdownLinkResolution: 'absolute' | 'relative' | 'shortest' |
| | | /** Strips folders from a link so that it looks nice */ |
| | | prettyLinks: boolean |
| | | indexAnchorLinks: boolean |
| | |
| | | const transformLink = (target: string) => { |
| | | const targetSlug = slugify(decodeURI(target).trim()) |
| | | if (opts.markdownLinkResolution === 'relative' && !path.isAbsolute(targetSlug)) { |
| | | // TODO |
| | | // return './' + relative(curSlug, targetSlug) |
| | | return './' + relative(curSlug, targetSlug) |
| | | } else { |
| | | return './' + relativeToRoot(curSlug, targetSlug) |
| | | } |
| | | // todo: handle shortest path |
| | | } |
| | | |
| | | const outgoing: Set<string> = new Set() |