Skip to content

Commit

Permalink
put the script in a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
OnkarRuikar committed Jan 23, 2025
1 parent 0b82d24 commit d2eada7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
<html>
<head>
<title>404 Page Not Found</title>
<script src="./404.js"></script>
</head>
<body>
<h1>404 Page Not Found</h1>
<script>
if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
const link = document.createElement("a");
link.href = `https://developer.mozilla.org${location.pathname}`;
link.textContent = "View on MDN production server";
document.body.appendChild(link);
}
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions .github/workflows/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
window.addEventListener("DOMContentLoaded", () => {
if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
const link = document.createElement("a");
link.href = `https://developer.mozilla.org${location.pathname}`;
link.textContent = "View on MDN production server";
document.body.appendChild(link);
}
});
1 change: 1 addition & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
# Add the custom 404 page to provide production links to the unbuilt documents
mkdir -p ${BUILD_OUT_ROOT}/en-us/_spas/
cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/_spas/404.html
cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/_spas/404.js
# Download the raw diff blob and store that inside the build
# directory.
Expand Down

0 comments on commit d2eada7

Please sign in to comment.