Skip to content

Commit fb537b5

Browse files
authored
Merge pull request polkadot-developers#325 from substrate-developer-hub/rp/infra
Add uri trailing slashes
2 parents 776ad03 + f1c3b2d commit fb537b5

24 files changed

+371
-196
lines changed

.netlify/_redirects_develop

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
## Production: Tutorial
2+
3+
### Tutorial - Create Your First Substrate Chain
4+
/docs/en/tutorials/create-your-first-substrate-chain /tutorials/v3/create-your-first-substrate-chain 301!
5+
/docs/en/tutorials/create-your-first-substrate-chain/* /tutorials/v3/create-your-first-substrate-chain 301!
6+
7+
### Tutorial - Add a Pallet to Your Runtime
8+
/docs/en/tutorials/add-a-pallet /tutorials/v3/add-a-pallet 301!
9+
/docs/en/tutorials/add-a-pallet/* /tutorials/v3/add-a-pallet 301!
10+
11+
### Tutorial - PoE
12+
/docs/en/tutorials/build-a-dapp /tutorials/v3/proof-of-existence 301!
13+
/docs/en/tutorials/build-a-dapp/* /tutorials/v3/proof-of-existence 301!
14+
15+
### Tutorial - Private Network
16+
/docs/en/tutorials/start-a-private-network /tutorials/v3/private-network 301!
17+
/docs/en/tutorials/start-a-private-network/* /tutorials/v3/private-network 301!
18+
19+
### Tutorial - Forkless Upgrade
20+
/docs/en/tutorials/forkless-upgrade /tutorials/v3/forkless-upgrades 301!
21+
/docs/en/tutorials/forkless-upgrade/* /tutorials/v3/forkless-upgrades 301!
22+
23+
### Tutorial - Permissioned Network
24+
/docs/en/tutorials/build-permission-network /tutorials/v3/permissioned-network 301!
25+
/docs/en/tutorials/build-permission-network/* /tutorials/v3/permissioned-network 301!
26+
27+
### Tutorial - Add a Contract Pallet
28+
/docs/en/tutorials/add-contracts-pallet /tutorials/v3/add-contracts 301!
29+
/docs/en/tutorials/add-contracts-pallet/* /tutorials/v3/add-contracts 301!
30+
31+
### Tutorial - Node Metrics
32+
/docs/en/tutorials/visualize-node-metrics /tutorials/v3/node-metrics 301!
33+
/docs/en/tutorials/visualize-node-metrics/* /tutorials/v3/node-metrics 301!
34+
35+
### Tutorial - Frontier
36+
/docs/en/tutorials/frontier /tutorials/v3/frontier 301!
37+
/docs/en/tutorials/frontier/* /tutorials/v3/frontier/* 301!
38+
39+
### Tutorial - Cumulus Workshop
40+
/tutorials/substrate-cumulus-workshop /tutorials/v3/cumulus/start-relay 301!
41+
/tutorials/substrate-cumulus-workshop/* /tutorials/v3/cumulus/start-relay 301!
42+
/cumulus-workshop /tutorials/v3/cumulus/start-relay 301!
43+
/cumulus-workshop/* /tutorials/v3/cumulus/start-relay 301!
44+
45+
### Tutorial - Kitties Workshop
46+
/tutorials/kitties /tutorials/v3/kitties 301!
47+
/tutorials/kitties/* /tutorials/v3/kitties 301!
48+
/kitties /tutorials/v3/kitties 301!
49+
/kitties/* /tutorials/v3/kitties 301!
50+
51+
### Tutorial page
52+
/en/tutorials /tutorials/v3 301!
53+
/en/tutorials/ /tutorials/v3 301!
54+
55+
## Production: How-to Guides & Recipes
56+
57+
/substrate-how-to-guides /how-to-guides/v3 301!
58+
/substrate-how-to-guides/* /how-to-guides/v3 301!
59+
/recipes /how-to-guides/v3 301!
60+
/recipes/* /how-to-guides/v3 301!
61+
62+
## Production: Knowledge Base
63+
64+
### Production: Getting Started
65+
/docs/en /v3/getting-started/overview 301!
66+
/docs/en/ /v3/getting-started/overview 301!
67+
/docs/en/knowledgebase/getting-started /v3/getting-started/installation 301!
68+
/docs/en/knowledgebase/getting-started/* /v3/getting-started/:splat 301!
69+
70+
### Knowledge Base: Key Concepts
71+
/docs/en/knowledgebase/learn-substrate/* /v3/concepts/:splat 301!
72+
/docs/en/knowledgebase/runtime /v3/concepts/runtime 301!
73+
/docs/en/knowledgebase/runtime/ /v3/concepts/runtime 301!
74+
75+
### Knowledge Base: Runtime Development
76+
/docs/en/knowledgebase/runtime/fees /v3/runtime/weights-and-fees 301!
77+
/docs/en/knowledgebase/runtime/* /v3/runtime/:splat 301!
78+
79+
### Knowledge Base: Smart Contract
80+
/docs/en/knowledgebase/smart-contracts /v3/smart-contracts/overview 301!
81+
/docs/en/knowledgebase/smart-contracts/ /v3/smart-contracts/overview 301!
82+
/docs/en/knowledgebase/smart-contracts/* /v3/smart-contracts/:splat 301!
83+
84+
### Knowledge Base: Integrate
85+
/docs/en/knowledgebase/integrate/* /v3/toolchains/:splat 301!
86+
87+
### Knowledge Base: Advanced
88+
/docs/en/knowledgebase/advanced/codec /v3/advanced/scale-codec 301!
89+
/docs/en/knowledgebase/advanced/codec/ /v3/advanced/scale-codec 301!
90+
/docs/en/knowledgebase/advanced/ss58-address-format /v3/advanced/ss58 301!
91+
/docs/en/knowledgebase/advanced/ss58-address-format/ /v3/advanced/ss58 301!
92+
/docs/en/knowledgebase/advanced/no-hash-collections /v3/advanced/hash-collections 301!
93+
/docs/en/knowledgebase/advanced/no-hash-collections/ /v3/advanced/hash-collections 301!
94+
/docs/en/knowledgebase/advanced/* /v3/advanced/:splat 301!
95+
96+
## Production: rustdocs
97+
/rustdocs/* https://paritytech.github.io/substrate/:splat 200
98+
99+
# ---------------
100+
# --- Others ----
101+
# ---------------
102+
103+
# Catch all
104+
/* / 301

.netlify/_redirects_production

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Netlify app domain
2+
https://substrate-docs.netlify.app/* https://docs.substrate.io/:splat 301!
13
## Production: Tutorial
24

35
### Tutorial - Create Your First Substrate Chain

gatsby-browser.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,35 @@ export const wrapRootElement = ({ element }) => (
2828
export const wrapPageElement = ({ element }) => (
2929
<MDXProvider components={components}>{element}</MDXProvider>
3030
)
31+
32+
export const onRouteUpdate = ({ location }) => scrollToAnchor(location)
33+
34+
/**
35+
*
36+
* @desc - a function to jump to the correct scroll position
37+
* @param {Object} location -
38+
* @param {Number} [mainNavHeight] - the height of any persistent nav -> document.querySelector(`nav`)
39+
*/
40+
function scrollToAnchor(location, mainNavHeight = 100) {
41+
// Check for location so build does not fail
42+
43+
if (location && location.hash) {
44+
// Fix scrolling for ids starting with numbers
45+
// https://stackoverflow.com/a/20306237/1268612
46+
const hash = location.hash.replace(/^#(\d)/, '#\\3$1')
47+
const item = document.querySelector(`${hash}`)
48+
49+
if (item)
50+
window.scrollTo({
51+
top: item.offsetTop - mainNavHeight,
52+
behavior: 'instant',
53+
})
54+
}
55+
56+
const bypassPages = ['/', '/tutorials/v3/', '/rustdocs/', '/playground/']
57+
if (location && bypassPages.includes(location.pathname)) {
58+
window.scrollTo(0, 0)
59+
}
60+
61+
return true
62+
}

gatsby-config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,11 @@ module.exports = {
293293
trackPageViews: true,
294294
},
295295
},
296+
{
297+
resolve: `gatsby-plugin-force-trailing-slashes`,
298+
options: {
299+
excludedPaths: [`/404.html`],
300+
},
301+
},
296302
],
297303
}

gatsby-node.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
// This param is used when `/[tutorials, how-to-guides]` are then redirected to
2-
// `/[tutorials, how-to-guides]/<defaultVersion>`.
1+
// This param is used when `/[tutorials, how-to-guides]/` are then redirected to
2+
// `/[tutorials, how-to-guides]/<defaultVersion>/`.
33
const defaultVersion = 'v3'
44

55
const redirects = [
6-
{ fromPath: '/tutorials', toPath: `/tutorials/${defaultVersion}` },
7-
{ fromPath: '/how-to-guides', toPath: `/how-to-guides/${defaultVersion}` },
8-
{ fromPath: '/v3', toPath: '/v3/getting-started/overview' },
9-
{ fromPath: '/v3/getting-started', toPath: '/v3/getting-started/overview' },
10-
{ fromPath: '/v3/concepts', toPath: '/v3/concepts/runtime' },
11-
{ fromPath: '/v3/runtime', toPath: '/v3/runtime/frame' },
12-
{ fromPath: '/v3/integration', toPath: '/v3/integration/polkadot-js' },
13-
{ fromPath: '/v3/advanced', toPath: '/v3/advanced/account-info' },
14-
{ fromPath: '/tutorials/v3/kitties', toPath: `/tutorials/v3/kitties/pt1` },
6+
{ fromPath: '/tutorials/', toPath: `/tutorials/${defaultVersion}/` },
7+
{ fromPath: '/how-to-guides/', toPath: `/how-to-guides/${defaultVersion}/` },
8+
{ fromPath: '/v3/', toPath: '/v3/getting-started/overview/' },
9+
{ fromPath: '/v3/getting-started/', toPath: '/v3/getting-started/overview/' },
10+
{ fromPath: '/v3/concepts/', toPath: '/v3/concepts/runtime/' },
11+
{ fromPath: '/v3/runtime/', toPath: '/v3/runtime/frame/' },
12+
{ fromPath: '/v3/integration/', toPath: '/v3/integration/polkadot-js/' },
13+
{ fromPath: '/v3/advanced/', toPath: '/v3/advanced/account-info/' },
14+
{ fromPath: '/tutorials/v3/kitties/', toPath: `/tutorials/v3/kitties/pt1/` },
1515
{
16-
fromPath: '/how-to-guides/basics',
17-
toPath: `/how-to-guides/v3/basics/pallet-integration`,
16+
fromPath: '/how-to-guides/basics/',
17+
toPath: `/how-to-guides/v3/basics/pallet-integration/`,
1818
},
1919
{
20-
fromPath: '/how-to-guides/pallet-design',
21-
toPath: `/how-to-guides/v3/pallet-design/contracts-pallet`,
20+
fromPath: '/how-to-guides/pallet-design/',
21+
toPath: `/how-to-guides/v3/pallet-design/contracts-pallet/`,
2222
},
2323
{
24-
fromPath: '/how-to-guides/weights',
25-
toPath: `/how-to-guides/v3/weights/calculate-fees`,
24+
fromPath: '/how-to-guides/weights/',
25+
toPath: `/how-to-guides/v3/weights/calculate-fees/`,
2626
},
2727
{
28-
fromPath: '/how-to-guides/testing',
29-
toPath: `/how-to-guides/v3/testing/basics`,
28+
fromPath: '/how-to-guides/testing/',
29+
toPath: `/how-to-guides/v3/testing/basics/`,
3030
},
3131
{
32-
fromPath: '/how-to-guides/storage-migrations',
33-
toPath: `/how-to-guides/v3/storage-migrations/basics`,
32+
fromPath: '/how-to-guides/storage-migrations/',
33+
toPath: `/how-to-guides/v3/storage-migrations/basics/`,
3434
},
3535
{
36-
fromPath: '/how-to-guides/consensus',
37-
toPath: `/how-to-guides/v3/consensus/pow`,
36+
fromPath: '/how-to-guides/consensus/',
37+
toPath: `/how-to-guides/v3/consensus/pow/`,
3838
},
3939
{
40-
fromPath: '/how-to-guides/parachains',
41-
toPath: `/how-to-guides/v3/parachains/connect`,
40+
fromPath: '/how-to-guides/parachains/',
41+
toPath: `/how-to-guides/v3/parachains/connect/`,
4242
},
4343
{
44-
fromPath: '/how-to-guides/tools',
45-
toPath: `/how-to-guides/v3/tools/try-runtime`,
44+
fromPath: '/how-to-guides/tools/',
45+
toPath: `/how-to-guides/v3/tools/try-runtime/`,
4646
},
4747
]
4848

netlify.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
publish = "public/"
44

55
[context.deploy-preview]
6-
command = "yarn build && cp .netlify/_headers_develop public/_headers"
6+
command = "yarn build && cp .netlify/_headers_develop public/_headers && cp .netlify/_redirects_develop public/_redirects"
77
publish = "public/"
88

99
[context.develop]
10-
command = "yarn build && cp .netlify/_headers_develop public/_headers"
10+
command = "yarn build && cp .netlify/_headers_develop public/_headers && cp .netlify/_redirects_develop public/_redirects"
1111
publish = "public/"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"gatsby": "^3.7.2",
2828
"gatsby-omni-font-loader": "^1.3.1",
2929
"gatsby-plugin-eslint": "^3.0.0",
30+
"gatsby-plugin-force-trailing-slashes": "^1.0.5",
3031
"gatsby-plugin-image": "^1.8.0",
3132
"gatsby-plugin-manifest": "^3.7.1",
3233
"gatsby-plugin-mdx": "^1.2.25",

src/components/BreadCrumbNav.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { LocalizedLink } from 'gatsby-theme-i18n'
2+
import Link from './Link'
33

44
interface BreadCrumbNavProps {
55
section: string
@@ -10,9 +10,9 @@ export default function BreadCrumbNav(props: BreadCrumbNavProps) {
1010
return (
1111
<>
1212
<div className="text-sm font-medium text-substrateBlue dark:text-substrateBlue-light capitalize mdx-anchor">
13-
<LocalizedLink to="/">Developers Home</LocalizedLink>
13+
<Link to="/">Developers Home</Link>
1414
<span className="px-2 text-substrateDark dark:text-white">»</span>
15-
<LocalizedLink to={props.sectionURL}>{props.section}</LocalizedLink>
15+
<Link to={props.sectionURL}>{props.section}</Link>
1616
<span className="px-2 text-substrateDark dark:text-white">»</span>
1717
<span className="text-substrateDark dark:text-white">
1818
{props.title}

src/components/Buttons/PrimaryButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { LocalizedLink } from 'gatsby-theme-i18n'
2+
import Link from '../Link'
33

44
interface PrimaryButtonProps {
55
link: string
@@ -24,14 +24,14 @@ export function PrimaryButton(props: PrimaryButtonProps) {
2424
</button>
2525
</a>
2626
) : (
27-
<LocalizedLink
27+
<Link
2828
className={`bg-substrateGreen ${padding()} hover:bg-white border-2 border-transparent hover:border-substrateGreen rounded text-white hover:text-substrateGreen transform transition duration-300 ease-in-out`}
2929
to={props.link}
3030
>
3131
<button className={`focus:outline-none font-bold ${textSize()}`}>
3232
{props.children}
3333
</button>
34-
</LocalizedLink>
34+
</Link>
3535
)}
3636
</>
3737
)

src/components/Buttons/SecondaryButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { LocalizedLink } from 'gatsby-theme-i18n'
2+
import Link from '../Link'
33

44
interface SecondaryButtonProps {
55
link: string
@@ -23,15 +23,15 @@ export function SecondaryButton(props: SecondaryButtonProps) {
2323
</div>
2424
</a>
2525
) : (
26-
<LocalizedLink to={props.link}>
26+
<Link to={props.link}>
2727
<div
2828
className={`bg-substrateDark dark:bg-substrateGray-light ${paddingSize()} ${textSize()} inline-block rounded-md hover:opacity-80 transition-opacity`}
2929
>
3030
<div className="font-bold mb-0 text-white dark:text-black">
3131
{props.children}
3232
</div>
3333
</div>
34-
</LocalizedLink>
34+
</Link>
3535
)}
3636
</>
3737
)

0 commit comments

Comments
 (0)