-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add redirects to new docs site
- Loading branch information
1 parent
1409de2
commit 5ef1bc8
Showing
5 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ dist | |
config.local.js | ||
basement_dist | ||
yarn.lock | ||
|
||
src/.vuepress/redirects.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fs = require('fs') | ||
|
||
const redirectsFilePath = 'src/.vuepress/public/_redirects' | ||
const outputFilePath = 'src/.vuepress/redirects.js' | ||
|
||
const lines = fs.readFileSync(redirectsFilePath, 'utf-8').split('\n') | ||
const routes = {} | ||
lines.forEach(line => { | ||
const [source, destination] = line.split(/\s+/) | ||
routes[source] = destination | ||
}) | ||
|
||
fs.writeFileSync(outputFilePath, `export default ${JSON.stringify(routes, null, 2)}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
import event from '@vuepress/plugin-pwa/lib/event' | ||
import redirects from './redirects' | ||
|
||
export default ({ router }) => { | ||
registerAutoReload(); | ||
|
||
router.addRoutes([ | ||
{ path: '/docs/', redirect: '/' }, | ||
{ path: '/docs/governance/attestation-station/', redirect: '/docs/identity' } | ||
{ path: '/docs/', redirect: '/' } | ||
]) | ||
|
||
// Custom redirect hack. | ||
router.beforeEach((to, from, next) => { | ||
const target = redirects[to.path] || redirects[to.path.replace(/\/$/, '')] | ||
if (target) { | ||
if (target.startsWith('http://') || target.startsWith('https://')) { | ||
if (typeof window !== 'undefined') { | ||
window.location.href = target | ||
} | ||
} else { | ||
next(target) | ||
} | ||
} else { | ||
next() | ||
} | ||
}) | ||
} | ||
|
||
// When new content is detected by the app, this will automatically | ||
// refresh the page, so that users do not need to manually click | ||
// the refresh button. For more details see: | ||
// https://linear.app/optimism/issue/FE-1003/investigate-archive-issue-on-docs | ||
const registerAutoReload = () => { | ||
event.$on('sw-updated', e => e.skipWaiting().then(() => { | ||
location.reload(true); | ||
})) | ||
event.$on('sw-updated', e => { | ||
e.skipWaiting().then(() => | ||
{ | ||
if (typeof location !== 'undefined') | ||
location.reload(true); | ||
} | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/docs/identity/atst-v1 https://docs.optimism.io/chain/identity/contracts-eas 301! | ||
/docs/identity/app https://docs.optimism.io/chain/identity/applications 301! | ||
/docs/identity/atst-v0 https://docs.optimism.io/chain/identity/about-attestations 301! | ||
/docs/identity/schemas https://docs.optimism.io/chain/identity/schemas 301! | ||
/docs/identity/glossary https://docs.optimism.io/connect/resources/glossary#op-profile--identity 301! | ||
/docs/identity/intro https://docs.optimism.io/chain/identity/overview 301! | ||
/docs/identity https://docs.optimism.io/chain/identity/overview 301! | ||
/docs/identity/build https://docs.optimism.io/chain/identity/about-attestations 301! | ||
/docs/identity/profile https://docs.optimism.io/chain/identity/optimist-profile 301! | ||
/docs/useful-tools/networks https://docs.optimism.io/chain/networks 301! | ||
/docs/useful-tools/providers https://docs.optimism.io/builders/tools/rpc-providers 301! | ||
/docs/useful-tools/faucets https://docs.optimism.io/builders/tools/faucets 301! | ||
/docs/useful-tools/meta-tx https://docs.optimism.io/builders/tools/account-abstraction 301! | ||
/docs/useful-tools/account-abstraction https://docs.optimism.io/builders/tools/account-abstraction 301! | ||
/docs/useful-tools https://docs.optimism.io/builders/tools/overview 301! | ||
/docs/useful-tools/oracles https://docs.optimism.io/builders/tools/oracles 301! | ||
/docs/useful-tools/debugging https://docs.optimism.io/builders/tools/overview 301! | ||
/docs/useful-tools/monitoring https://docs.optimism.io/builders/tools/monitoring/analytics-tools 301! | ||
/docs/useful-tools/explorers https://docs.optimism.io/builders/tools/block-explorers 301! | ||
/docs/protocol/txn-flow https://docs.optimism.io/stack/protocol/transaction-flow 301! | ||
/docs/protocol/withdrawal-flow https://docs.optimism.io/stack/protocol/withdrawal-flow 301! | ||
/docs/protocol https://docs.optimism.io/stack/protocol/overview 301! | ||
/docs/protocol/2-rollup-protocol https://docs.optimism.io/stack/protocol/overview 301! | ||
/docs/protocol/1-design-philosophy https://docs.optimism.io/stack/protocol/design-principles 301! | ||
/docs/protocol/deposit-flow https://docs.optimism.io/stack/protocol/deposit-flow 301! | ||
/docs/protocol/protocol-2.0 https://docs.optimism.io/stack/protocol/overview 301! | ||
/docs/sdk/js-client https://docs.optimism.io/builders/tools/javascript/sdk 301! | ||
/docs/sdk/alchemy-sdk https://docs.optimism.io/builders/tools/javascript/sdk 301! | ||
/docs/sdk https://docs.optimism.io/builders/tools/javascript/sdk 301! | ||
/docs/guides/wallet-dev https://docs.optimism.io/builders/cex-wallet-developers/wallet-support 301! | ||
/docs/guides/cex-dev https://docs.optimism.io/builders/cex-wallet-developers/cex-support 301! | ||
/docs/guides/testing https://docs.optimism.io/chain/testing/testing-dapps 301! | ||
/docs/guides https://docs.optimism.io 301! | ||
/docs/guides/nft https://docs.optimism.io 301! | ||
/docs/guides/bridge-dev https://docs.optimism.io/builders/dapp-developers/bridging/basics 301! | ||
/docs/security-model https://docs.optimism.io/chain/security/faq 301! | ||
/docs/security-model/priv-roles https://docs.optimism.io/chain/security/privileged-roles 301! | ||
/docs/security-model/bounties https://docs.optimism.io/chain/security/security-policy 301! | ||
/docs/developers/bridge/basics https://docs.optimism.io/builders/dapp-developers/bridging/basics 301! | ||
/docs/developers/bridge/messaging https://docs.optimism.io/builders/dapp-developers/bridging/messaging 301! | ||
/docs/developers/bridge/comm-strategies https://docs.optimism.io/builders/dapp-developers/bridging/messaging 301! | ||
/docs/developers/bridge/standard-bridge https://docs.optimism.io/builders/dapp-developers/bridging/standard-bridge 301! | ||
/docs/developers/known-issues https://docs.optimism.io/chain/differences 301! | ||
/docs/developers/bedrock/node-operator-guide https://docs.optimism.io/builders/node-operators/overview 301! | ||
/docs/developers/bedrock/explainer https://docs.optimism.io/stack/protocol/overview 301! | ||
/docs/developers/bedrock/metrics https://docs.optimism.io/builders/node-operators/metrics 301! | ||
/docs/developers/bedrock/wallet-upgrade https://docs.optimism.io 301! | ||
/docs/developers/bedrock/differences https://docs.optimism.io 301! | ||
/docs/developers https://docs.optimism.io 301! | ||
/docs/developers/media https://docs.optimism.io 301! | ||
/docs/developers/build/dev-node https://docs.optimism.io/chain/testing/dev-node 301! | ||
/docs/developers/build/json-rpc https://docs.optimism.io/builders/node-operators/json-rpc 301! | ||
/docs/developers/build/system-contracts https://docs.optimism.io/builders/dapp-developers/contracts/system-contracts 301! | ||
/docs/developers/build/testing-dapps https://docs.optimism.io/builders/dapp-developers/contracts/testing 301! | ||
/docs/developers/build/transaction-fees https://docs.optimism.io/stack/transactions/transaction-fees 301! | ||
/docs/developers/build/cheap-dapp https://docs.optimism.io/builders/dapp-developers/contracts/optimization 301! | ||
/docs/developers/build/differences https://docs.optimism.io/chain/differences 301! | ||
/docs/developers/nodes/intro https://docs.optimism.io/builders/node-operators/overview 301! | ||
/docs/developers/nodes/mainnet https://docs.optimism.io/builders/node-operators/overview 301! | ||
/docs/developers/nodes/testnet https://docs.optimism.io/builders/node-operators/overview 301! |