Skip to content

Commit 1a27d54

Browse files
authored
Merge pull request #1119 from ethereum-optimism/lint-check
Automate Internal Link Updates Using Redirects File
2 parents 3dc670f + 2da87a6 commit 1a27d54

File tree

17 files changed

+365
-19
lines changed

17 files changed

+365
-19
lines changed

lychee.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ exclude = [
4141
]
4242

4343
# Accept these status codes
44-
accept = ["100..=103", "200..=299", "403..=403", "502..=502"]
44+
accept = ["100..=103", "200..=299", "403..=403", "502..=502"]

notes/fix-redirects.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Redirect links management guide
2+
3+
## Scripts overview
4+
Two scripts help maintain internal links when pages are redirected:
5+
6+
* `check-redirects`: Identifies links that need updating based on the `_redirects` file.
7+
* `fix-redirects`: Automatically updates links to match `_redirects` entries.
8+
9+
## Checking for broken links
10+
11+
Run the check script:
12+
13+
```bash
14+
pnpm lint //OR
15+
pnpm check-redirects
16+
```
17+
## What it does
18+
19+
* Scans all `.mdx` files in the docs
20+
* Compares internal links against `_redirects` file
21+
* Reports any outdated links that need updating
22+
* Provides a summary of total, broken, and valid links
23+
24+
## Example output
25+
26+
```bash
27+
File "builders/overview.mdx" contains outdated link "/chain/overview" - should be updated to "/stack/overview"
28+
29+
Summary:
30+
Total pages 🔍 - 50
31+
Pages broken 🚫 - 2
32+
Pages OK ✅ - 48
33+
34+
```
35+
36+
## Fixing broken links
37+
38+
Fix links automatically:
39+
40+
```bash
41+
pnpm fix //OR
42+
pnpm fix-redirects
43+
```
44+
45+
## What it does
46+
47+
* Updates all internal links to match `_redirects` entries
48+
* Preserves other content and formatting
49+
* Shows which files and links were updated
50+
* Provides a summary of changes made
51+
52+
## Example output
53+
54+
```bash
55+
Fixed in "builders/overview.mdx": /chain/overview → /stack/overview
56+
57+
Summary:
58+
Total files 🔍 - 50
59+
Files fixed ✅ - 2
60+
Files skipped ⏭️ - 48
61+
```
62+
63+
## Best practices
64+
65+
1. Before running
66+
67+
* Commit current changes
68+
* Review `_redirects` file is up-to-date
69+
* Run `check-redirects` first to preview changes
70+
71+
72+
2. After running
73+
74+
* Review git diff of updated files
75+
* Test updated links locally
76+
* Commit changes with descriptive message
77+
78+
79+
80+
## Common issues
81+
82+
* Script fails: Ensure `_redirects` file exists in public folder, it should always be there!
83+
* No broken links found: Verify `_redirects` entries are correct.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"version": "0.0.1",
44
"description": "Optimism Docs",
55
"scripts": {
6-
"lint": "eslint . --ext mdx --max-warnings 0 && pnpm spellcheck:lint && pnpm check-breadcrumbs",
7-
"fix": "eslint . --ext mdx --fix && pnpm spellcheck:fix && pnpm check-breadcrumbs",
6+
"lint": "eslint . --ext mdx --max-warnings 0 && pnpm spellcheck:lint && pnpm check-breadcrumbs && pnpm check-redirects",
7+
"fix": "eslint . --ext mdx --fix && pnpm spellcheck:fix && pnpm check-breadcrumbs && pnpm fix-redirects",
88
"spellcheck:lint": "cspell lint \"**/*.mdx\"",
99
"spellcheck:fix": "cspell --words-only --unique \"**/*.mdx\" | sort --ignore-case | uniq > words.txt",
1010
"linkcheck": "lychee --config ./lychee.toml --quiet \"./pages\"",
1111
"breadcrumbs":"npx ts-node --skip-project utils/create-breadcrumbs.ts",
12+
"check-redirects": "npx ts-node --skip-project utils/redirects.ts",
13+
"fix-redirects": "npx ts-node --skip-project utils/fix-redirects.ts",
1214
"check-breadcrumbs":"npx ts-node --skip-project utils/breadcrumbs.ts",
1315
"index:docs": "npx ts-node --skip-project utils/algolia-indexer.ts",
1416
"dev": "next dev",

pages/builders.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Welcome to the Builders section. Here you'll find resources and guides for devel
1515
<Card title="App Developers" href="/builders/app-developers" />
1616
<Card title="Chain Operators" href="/builders/chain-operators" />
1717
<Card title="Node Operators" href="/builders/node-operators" />
18-
<Card title="Wallets & CEXs" href="/builders/cex-wallet-developers" />
18+
<Card title="Wallets & CEXs" href="/builders/app-developers/overview" />
1919
<Card title="Developer Tools" href="/builders/tools" />
2020
</Cards>

pages/builders/app-developers/overview.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ In this area of the Optimism Docs you'll find everything you need to know about
1616
If you're brand new to OP Mainnet, try starting with the guide on [deploying a basic contract](/chain/getting-started).
1717
It'll get you familiar with the basic steps required to get a contract deployed to the network.
1818
OP Mainnet is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306) so you can feel confident that your existing Ethereum smart contract skills will carry over to OP Mainnet.
19-
Just make sure to be aware of the few small [differences between Ethereum and OP Mainnet](/chain/differences).
19+
Just make sure to be aware of the few small [differences between Ethereum and OP Mainnet](/stack/differences).
2020

2121
You might also want to check out the [testing on OP Networks guide](/chain/testing/testing-apps) and the tutorial on [running a local development environment](/chain/testing/dev-node) to help you feel totally confident in your OP Mainnet deployment.
2222

2323
<Cards>
24-
<Card title="Deploying Your First Contract to OP Mainnet" href="/builders/app-developers/tutorials/first-contract" icon={<img src="/img/icons/shapes.svg" />} />
24+
<Card title="Deploying Your First Contract to OP Mainnet" href="/builders/app-developers/overview" icon={<img src="/img/icons/shapes.svg" />} />
2525

26-
<Card title="Solidity Compatibility on OP Mainnet" href="/builders/app-developers/contracts/compatibility" icon={<img src="/img/icons/shapes.svg" />} />
26+
<Card title="Solidity Compatibility on OP Mainnet" href="/stack/differences" icon={<img src="/img/icons/shapes.svg" />} />
2727

2828
<Card title="Testing Apps on OP Mainnet" href="/chain/testing/testing-apps" icon={<img src="/img/icons/shapes.svg" />} />
2929
</Cards>

pages/builders/app-developers/tutorials/cross-dom-bridge-erc20.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Make sure to check out the [Standard Bridge guide](/builders/app-developers/brid
3131

3232
The Optimism SDK supports any of the [Superchain networks](/chain/networks).
3333
[Some Superchain networks](https://sdk.optimism.io/enums/l2chainid) are already included in the SDK by default.
34-
If you want to use a network that isn't included by default, you can simply [instantiate the SDK with the appropriate contract addresses](/builders/chain-operators/tutorials/sdk).
34+
If you want to use a network that isn't included by default, you can simply [instantiate the SDK with the appropriate contract addresses](/builders/app-developers/overview).
3535

3636
## Dependencies
3737

pages/builders/chain-operators/tutorials.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ This section provides information on adding attributes to the derivation functio
2323

2424
<Card title="Modifying predeployed contracts" href="/builders/chain-operators/tutorials/modifying-predeploys" />
2525

26-
<Card title="Using viem" href="/builders/chain-operators/tutorials/sdk" />
26+
<Card title="Using viem" href="/builders/app-developers/overview" />
2727
</Cards>

pages/chain/getting-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Steps } from 'nextra/components'
1111
This guide explains the basics of OP Mainnet development.
1212
OP Mainnet is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), meaning we run a slightly modified version of the same `geth` you run on mainnet.
1313
Therefore, the differences between OP Mainnet development and Ethereum development are minor.
14-
But a few differences [do exist](/chain/differences).
14+
But a few differences [do exist](/stack/differences).
1515

1616
## OP Mainnet and OP Sepolia endpoint URLs
1717

pages/chain/testing/dev-node.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ We generally recommend using the local development environment if your applicati
2424

2525
1. **You're building contracts on both OP Mainnet and Ethereum that need to interact with one another.** The local development environment is a great way to quickly test interactions between L1 and L2. The OP Mainnet and test networks have a communication delay between L1 and L2 that can make testing slow during the early stages of development.
2626

27-
2. **You're building an application that might be subject to one of the few [differences between Ethereum and OP Mainnet](/chain/differences).** Although OP Mainnet is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), it's not exactly the same as Ethereum. If you're building an application that might be subject to one of these differences, you should use the local development environment to double check that everything is running as expected. You might otherwise have unexpected issues when you move to testnet. We strongly recommend reviewing these differences carefully to see if you might fall into this category.
27+
2. **You're building an application that might be subject to one of the few [differences between Ethereum and OP Mainnet](/stack/differences).** Although OP Mainnet is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), it's not exactly the same as Ethereum. If you're building an application that might be subject to one of these differences, you should use the local development environment to double check that everything is running as expected. You might otherwise have unexpected issues when you move to testnet. We strongly recommend reviewing these differences carefully to see if you might fall into this category.
2828

2929
However, not everyone will need to use the local development environment.
3030
OP Mainnet is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), which means that OP Mainnet looks almost exactly like Ethereum under the hood.

pages/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Whether you're a developer building a app on OP Mainnet, a node operator running
2222

2323
<Card title="Node operators" href="/builders/node-operators/rollup-node" icon={<img src="img/icons/computer-line.svg" />} />
2424

25-
<Card title="Wallets & CEXs" href="/builders/cex-wallet-developers/wallet-support" icon={<img src="img/icons/wallet.svg" />} />
25+
<Card title="Wallets & CEXs" href="/builders/app-developers/overview" icon={<img src="img/icons/wallet.svg" />} />
2626

2727
<Card title="Developer tools" href="/builders/tools/overview" icon={<img src="img/icons/tools.svg" />} />
2828

0 commit comments

Comments
 (0)