Skip to content

Commit

Permalink
HOT-FIX: swizzle NotFoundContent to old docs (#294)
Browse files Browse the repository at this point in the history
* fix: swizzle NotFoundContent to old docs

* chore: add get help discord link
  • Loading branch information
RetricSu authored Apr 12, 2024
1 parent cd495c3 commit 6144117
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
27 changes: 27 additions & 0 deletions website/src/theme/NotFound/Content/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { useLocation } from "@docusaurus/router";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import styles from "./styles.module.css";

// according to docusaurus, unwrap NotFoundContent is danger
// we can undo this after there is no broken link from v1
export default function ContentWrapper(props) {
const location = useLocation();
const { siteConfig } = useDocusaurusContext();
const oldDocUrl = siteConfig.customFields.oldDocSiteUrl;
return (
<div className={styles.notFoundContainer}>
<h1>Page Not Found</h1>
<p>Are you trying to visit broken links from old doc website?</p>
<h2>
Try{" "}
<a href={oldDocUrl + location.pathname}>
{oldDocUrl + location.pathname}
</a>{" "}
</h2>
<div>
Or get help from <a href="https://discord.gg/nervosnetwork">discord</a>
</div>
</div>
);
}
9 changes: 9 additions & 0 deletions website/src/theme/NotFound/Content/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import '@css/customVariables.css';

.notFoundContainer {
width: auto;
margin: 0 auto;
padding: 1.5em 1em;
color: var(--text-secondary) !important;
text-align: center;
}
2 changes: 1 addition & 1 deletion website/static/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ window.addEventListener("DOMContentLoaded", function () {
const oldSiteLink = document.createElement("div");
oldSiteLink.innerHTML = `<div id="oldSiteLink">
<div>
<span>Note we've completely rebuilt Nervos Doc site! </span><span>For the old doc site, please see <a href="https://nervos-ckb-docs-git-v1-cryptape.vercel.app/">docs-old</a>.</span>
<span>Note we've completely rebuilt Nervos Doc site! </span><span>For the old doc site, please see <a href="https://docs-old.nervos.org">docs-old</a>.</span>
</div>
</div>`;
document.querySelector("body").prepend(oldSiteLink);
Expand Down

0 comments on commit 6144117

Please sign in to comment.