Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
as allowing the metalsmith link-checker to work properly.
USAGE:
provide metalsmith.data.root.websiteRoot for use in templates
absoluteUrl({ property: "websiteRoot", define: "/hello/world" })
convert all URLs beginning with websiteRoot to relative URLs
absoluteUrl({ resolve: "/hello/world", canonical: "https://example.org/" })
*/
const path = require('path');
const cheerio = require('cheerio');
const URI = require('urijs');
const urlSelector = Object.keys(URI.domAttributes).map(function(tagName) {
return tagName + '[' + URI.domAttributes[tagName] + ']';
}).join(',');
function filter(file, files, filePath /*, options */) {
// skip mutations for anything that isn't html
if (filePath.ext !== '.html') {
return true;
}
return false;
}
function transform($, file, fileName, options) {
const absolute = path.join(options.resolve, fileName);
if (options.canonical) {
const canonical = options.canonical + fileName;
const urlSelector = Object.keys(URI.domAttributes).map(function(tagName) {
return tagName + '[' + URI.domAttributes[tagName] + ']';
}).join(',');