diff --git a/layouts/download-current.hbs b/layouts/download-current.hbs
index 0c3b1386f427c..a5e286d881b6d 100644
--- a/layouts/download-current.hbs
+++ b/layouts/download-current.hbs
@@ -11,7 +11,7 @@
-
+ {{{contents}}}
{{> primary-download-matrix version=project.latestVersions.current versionTypeCurrent="true"}}
{{> secondary-download-matrix version=project.latestVersions.current versionTypeCurrent="true"}}
diff --git a/layouts/download.hbs b/layouts/download.hbs
index e8e62eecc10a2..ebd831fd268a1 100644
--- a/layouts/download.hbs
+++ b/layouts/download.hbs
@@ -11,7 +11,7 @@
-
+ {{{contents}}}
{{> primary-download-matrix version=project.latestVersions.lts versionTypeLts="true"}}
{{> secondary-download-matrix version=project.latestVersions.lts versionTypeLts="true"}}
diff --git a/layouts/partials/footer.hbs b/layouts/partials/footer.hbs
index d1142113caced..6b7e62120ed5e 100644
--- a/layouts/partials/footer.hbs
+++ b/layouts/partials/footer.hbs
@@ -9,6 +9,7 @@
+ - {{site.editOnGithub}}
- {{site.reportNodeIssue}}
- {{site.reportWebsiteIssue}}
- {{site.getHelpIssue}}
diff --git a/locale/en/site.json b/locale/en/site.json
index ae78837037d80..a14f0e55b881e 100644
--- a/locale/en/site.json
+++ b/locale/en/site.json
@@ -1,5 +1,6 @@
{
"title": "Node.js",
+ "editOnGithub":"Edit On GitHub",
"author": "Node.js",
"url": "https://nodejs.org/en/",
"locale": "en",
diff --git a/scripts/plugins/githubLinks.js b/scripts/plugins/githubLinks.js
index 06aa4a6e23bc7..f6cdf9230456f 100644
--- a/scripts/plugins/githubLinks.js
+++ b/scripts/plugins/githubLinks.js
@@ -1,24 +1,25 @@
'use strict'
+const sep = require('path').sep
+// add suffix (".html" or sep for windows test) to each part of regex
+// to ignore possible occurrences in titles (e.g. blog posts)
+const isEditable = `(security|index).html|(about|download|docs|foundation|get-involved|knowledge)\\${sep}`
+const isEditableReg = new RegExp(isEditable)
+
// This middleware adds "Edit on GitHub" links to every editable page
function githubLinks (options) {
return (files, m, next) => {
- // add suffix (".html" or "/") to each part of regex
- // to ignore possible occurrences in titles (e.g. blog posts)
- const isEditable = /security\.html|about\/|docs\/|foundation\/|get-involved\/|knowledge\//
-
Object.keys(files).forEach((path) => {
- if (!isEditable.test(path)) {
+ if (!isEditableReg.test(path)) {
return
}
const file = files[path]
- const url = `https://github.com/nodejs/nodejs.org/edit/master/locale/${options.locale}/${path.replace('.html', '.md')}`
- const editText = options.site.editOnGithub || 'Edit on GitHub'
+ path = path.replace('.html', '.md').replace(/\\/g, '/')
+ const url = `https://github.com/nodejs/nodejs.org/edit/master/locale/${options.locale}/${path}`
- const contents = file.contents.toString().replace(/(.*?)<\/h1>/, (match, $1, $2) => {
- return `${editText} ${$2}
`
- })
+ const contents = file.contents.toString() +
+ ` `
file.contents = Buffer.from(contents)
})
diff --git a/static/js/main.js b/static/js/main.js
index 49a5413aec27b..3c8af327d699a 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -246,3 +246,17 @@
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 (editOnGitHubUrlElement) {
+ editOnGitHubElement.setAttribute('href', editOnGitHubUrlElement.value)
+ } else {
+ editOnGitHubElement.parentNode.parentNode.removeChild(editOnGitHubElement.parentNode)
+ }
+})()