From 9474533aad747c663a1e5e564425406293443980 Mon Sep 17 00:00:00 2001
From: DongWei
Date: Sat, 8 Oct 2022 09:55:17 +0800
Subject: [PATCH] remove useless js snippets of codes for "Edit On GitHub"
We don't need to implement it through the client side but serve side
only by generating them together.
Refs: https://github.com/nodejs/nodejs.org/pull/4315.
---
build.js | 2 +-
layouts/partials/footer.hbs | 6 ++----
scripts/plugins/githubLinks.js | 16 ++++++++++++----
static/js/main.js | 19 -------------------
4 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/build.js b/build.js
index 909132bfbe188..e419eb2698366 100755
--- a/build.js
+++ b/build.js
@@ -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({
@@ -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))
diff --git a/layouts/partials/footer.hbs b/layouts/partials/footer.hbs
index 5f42d3d35b9ff..e71fec27d4f6e 100644
--- a/layouts/partials/footer.hbs
+++ b/layouts/partials/footer.hbs
@@ -14,10 +14,8 @@
Trademark Policy |
Trademark List |
Cookie Policy
-
-
+
+
diff --git a/scripts/plugins/githubLinks.js b/scripts/plugins/githubLinks.js
index 53d4d07525949..33a501b501547 100644
--- a/scripts/plugins/githubLinks.js
+++ b/scripts/plugins/githubLinks.js
@@ -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() +
- ` `;
+ const editOnGitHubTrans = options.site.editOnGithub || 'Edit on GitHub';
+ const replCallBack = (match, $1, $2) => {
+ return ``;
+ };
+ const contents = file.contents
+ .toString()
+ .replace(
+ /