Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: keep # fragments in Further Reading links on new docs site #15888

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/.eleventy.js
Expand Up @@ -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 `
<article class="resource">
<div class="resource__image">
<img class="resource__img" width="75" height="75" src="${metadata.logo}" alt="Avatar image for ${domain}" />
</div>
<div class="resource__content">
<a href="${metadata.url}" class="resource__title"> ${metadata.title} </a><br>
<a href="${href}" class="resource__title"> ${metadata.title} </a><br>
<span class="resource__domain"> ${domain}</span>
</div>
<svg class="c-icon resource__icon" width="13" height="12" viewBox="0 0 13 12" fill="none">
Expand Down