diff --git a/.github/workflows/404.html b/.github/workflows/404.html new file mode 100644 index 000000000000000..eb1805252fa03ab --- /dev/null +++ b/.github/workflows/404.html @@ -0,0 +1,11 @@ + + + + 404 Page Not Found + + + +

404 Page Not Found

+

Note: This is a GitHub pull request preview, and this page is not a part of the pull request.

+ + diff --git a/.github/workflows/404.js b/.github/workflows/404.js new file mode 100644 index 000000000000000..427b1de2810e269 --- /dev/null +++ b/.github/workflows/404.js @@ -0,0 +1,13 @@ +function getContentsAfterHost() { + const full = location.href; + const path = location.pathname; + + return full.substring(full.indexOf(path)); +} + +window.addEventListener("DOMContentLoaded", () => { + const link = document.createElement("a"); + link.href = `https://developer.mozilla.org${getContentsAfterHost()}`; + link.textContent = "View on MDN production server"; + document.body.appendChild(link); +}); diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 68f3dc5cd3dba5a..3276792a30fee8e 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -123,6 +123,11 @@ jobs: run: | # Exclude the .map files, as they're used for debugging JS and CSS. rsync -a --exclude "*.map" node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT + + # Add the custom 404 page to provide production links to the unbuilt documents + cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/404/index.html + cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/404/index.js + # Show the final disk usage size of the build. du -sh $BUILD_OUT_ROOT