Skip to content

Commit a44664f

Browse files
committed
fix(ci/preview): add custom 404 page
1 parent 667705a commit a44664f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

.github/workflows/404.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>404 Page Not Found</title>
5+
<script src="/en-US/_spas/404.js"></script>
6+
</head>
7+
<body>
8+
<h1>404 Page Not Found</h1>
9+
</body>
10+
</html>

.github/workflows/404.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
window.addEventListener("DOMContentLoaded", () => {
2+
if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
3+
const link = document.createElement("a");
4+
link.href = `https://developer.mozilla.org${location.pathname}`;
5+
link.textContent = "View on MDN production server";
6+
document.body.appendChild(link);
7+
}
8+
});

.github/workflows/pr-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ jobs:
105105
# Save the PR number into the build
106106
echo ${{ github.event.number }} > ${BUILD_OUT_ROOT}/NR
107107
108+
# Add the custom 404 page to provide production links to the unbuilt documents
109+
mkdir -p ${BUILD_OUT_ROOT}/en-us/_spas/
110+
cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/_spas/404.html
111+
cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/_spas/404.js
112+
108113
# Download the raw diff blob and store that inside the build
109114
# directory.
110115
# The purpose of this is for the PR Review Companion to later

0 commit comments

Comments
 (0)