Skip to main content
Module

x/lume/plugins/relative_urls.ts

πŸ”₯ Static site generator for Deno πŸ¦•
Very Popular
Go to Latest
File
import { posix } from "../deps/path.ts";import modifyUrls from "./modify_urls.ts";
import type { Site } from "../core.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.data.url as string); return posix.relative(from, url); }, })); };}