Modify URLs

The modify_urls plugin modifies all URLs in your HTML documents using a function. It's used internally by other plugins like resolve_urls, relative_urls and base_path but you can use it to modify the urls in a different way.

To use it, just import in the _config.js file and create a callback to change the url. For example, let's say we want to convert all urls to lowercase:

import modifyUrls from "lume/plugins/modify_urls.ts";

  fn: (url) => url.toLowerCase();

The plugin will search all urls in your HTML documents (elements with href, src, srcset and imagesrcset attributes) and invoke the callback for every url found. The callback has two arguments: the url and the Page instance where that url was found.