deno.land / x / lume@v2.1.4 / plugins / relative_urls.ts

relative_urls.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { 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); }, })); };}
lume

Version Info

Tagged at
5 months ago