diff --git a/docs/.eleventy.js b/docs/.eleventy.js index b9e27c8fd7b..deeecd4fbc8 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -129,13 +129,27 @@ module.exports = function(eleventyConfig) { const the_url = (new URL(link)); // same as url const domain = the_url.hostname; + let href = metadata.url; + + /* + * Restore `#` fragment from the original link. At this point, the fragment may have been lost + * during the process if `got` encountered redirects or if `metascraper` has found URL in the HTML document. + */ + if (!href.includes("#")) { + const originalFragmentMatch = /#(?:.)+/u.exec(link); + + if (originalFragmentMatch) { + href += originalFragmentMatch[0]; + } + } + return `
Avatar image for ${domain}
- ${metadata.title}
+ ${metadata.title}
${domain}