Skip to content

[pull] main from nodejs:main #81

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

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ function buildLocale(source, locale, opts) {
})
)
.use(markdown(markedOptions))
.use(githubLinks({ locale, site: i18nJSON(locale) }))
// Set pretty permalinks, we don't want .html suffixes everywhere.
.use(
permalinks({
Expand Down Expand Up @@ -195,6 +194,7 @@ function buildLocale(source, locale, opts) {
.use(hbsReg())
.use(scriptReg())
.use(layouts())
.use(githubLinks({ locale, site: i18nJSON(locale) }))
// Pipes the generated files into their respective subdirectory in the build
// directory.
.destination(path.join(__dirname, 'build', locale))
Expand Down
6 changes: 2 additions & 4 deletions layouts/partials/footer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
<a href="https://trademark-policy.openjsf.org">Trademark Policy</a> |
<a href="https://trademark-list.openjsf.org">Trademark List</a> |
<a href="https://www.linuxfoundation.org/cookies">Cookie Policy</a>
</p>
<div class="openjsfoundation-footer-edit">
| <a id="editOnGitHubLink" href="#">{{site.editOnGithub}}</a>
</div>
</p>
<div class="openjsfoundation-footer-edit"></div>
</div>
</div>

Expand Down
16 changes: 12 additions & 4 deletions scripts/plugins/githubLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ function githubLinks(options) {
const file = files[path];
path = path.replace('.html', '.md').replace(/\\/g, '/');
const url = `https://github.com/nodejs/nodejs.org/edit/main/locale/${options.locale}/${path}`;

const contents =
file.contents.toString() +
` <input type = "hidden" id = "editOnGitHubUrl" value="${url}"/> `;
const editOnGitHubTrans = options.site.editOnGithub || 'Edit on GitHub';
const replCallBack = (match, $1, $2) => {
return `<div class="openjsfoundation-footer-edit">
| <a href="${url}">${editOnGitHubTrans}</a>
</div>`;
};
const contents = file.contents
.toString()
.replace(
/<div class="openjsfoundation-footer-edit"><\/div>/,
replCallBack
);

file.contents = Buffer.from(contents);
});
Expand Down
19 changes: 0 additions & 19 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,3 @@
winText.textContent = winText.textContent.replace(/x(86|64)/, arch);
}
})();
(function () {
// This function is used to replace the anchor
// link of Edit on GitHub

var editOnGitHubElement = document.getElementById('editOnGitHubLink');
var editOnGitHubUrlElement = document.getElementById('editOnGitHubUrl');

if (!editOnGitHubElement) {
return;
}

if (editOnGitHubUrlElement) {
editOnGitHubElement.setAttribute('href', editOnGitHubUrlElement.value);
} else {
editOnGitHubElement.parentNode.parentNode.removeChild(
editOnGitHubElement.parentNode
);
}
})();