deno.land / x / lume@v2.1.4 / plugins / relative_urls.ts
123456789101112131415161718192021222324252627import { posix } from "../deps/path.ts";import modifyUrls from "./modify_urls.ts";
import type Site from "../core/site.ts";
/** A plugin to convert all internal URLs to relative */export default function () { return (site: Site) => { const basePath = site.options.location.pathname;
site.use(modifyUrls({ fn(url, page) { if (!url.startsWith("/") || url.startsWith("//")) { return url; }
if (!url.startsWith(basePath)) { url = posix.join(basePath, url); }
const from = site.url(page.outputPath); return posix.relative(posix.dirname(from), url); }, })); };}
Version Info