Skip to content

Commit d7e7926

Browse files
committedDec 23, 2021
feat(website): add traling slash to all URLs
1 parent 7d17732 commit d7e7926

19 files changed

+55
-34
lines changed
 

‎website/gatsby-node.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const replacePath = (_path) =>
2+
_path === `/` ? _path : _path.replace(/\/$|$/, `/`)
3+
4+
const excludedPaths = [`/404.html`]
5+
6+
exports.onCreatePage = async ({ page, actions }) => {
7+
const { createPage, deletePage } = actions
8+
9+
return new Promise(resolve => {
10+
if(!excludedPaths.includes(page.path)) {
11+
const oldPage = Object.assign({}, page)
12+
page.path = replacePath(page.path)
13+
if (page.path !== oldPage.path) {
14+
deletePage(oldPage)
15+
createPage(page)
16+
}
17+
}
18+
19+
resolve()
20+
})
21+
}

‎website/src/components/HeaderNav.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import * as nav from '../data/nav'
99
export const HeaderNav = () => {
1010
return (
1111
<Container>
12-
<HeaderInternalLink to="/about">About</HeaderInternalLink>
13-
<HeaderInternalLink to="/references">References</HeaderInternalLink>
14-
<HeaderInternalLink to="/components">Components</HeaderInternalLink>
12+
<HeaderInternalLink to="/about/">About</HeaderInternalLink>
13+
<HeaderInternalLink to="/references/">References</HeaderInternalLink>
14+
<HeaderInternalLink to="/components/">Components</HeaderInternalLink>
1515
<HeaderItem>
1616
Guides
1717
<HeaderSub>
@@ -22,7 +22,7 @@ export const HeaderNav = () => {
2222
))}
2323
</HeaderSub>
2424
</HeaderItem>
25-
<HeaderInternalLink to="/faq">FAQ</HeaderInternalLink>
25+
<HeaderInternalLink to="/faq/">FAQ</HeaderInternalLink>
2626
<HeaderExternalLink
2727
href="https://nivo.rocks/storybook/"
2828
target="_blank"

‎website/src/components/components/explorer/ComponentsExplorer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ComponentsExplorer = ({ location, navigate }) => {
2020
if (term) params.append('q', term)
2121
if (filter) params.append('filter', filter)
2222

23-
navigate(`/components?${params.toString()}`, {
23+
navigate(`/components/?${params.toString()}`, {
2424
replace: true,
2525
})
2626
},
@@ -32,7 +32,7 @@ const ComponentsExplorer = ({ location, navigate }) => {
3232
if (term) params.append('q', term)
3333
if (filter) params.append('filter', filter)
3434

35-
navigate(`/components?${params.toString()}`)
35+
navigate(`/components/?${params.toString()}`)
3636
},
3737
[term, navigate]
3838
)

‎website/src/components/home/HomeBar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Home = ({ colors, nivoTheme, isHorizontal = false }) => {
1818
: ['hot dogs', 'burgers', 'sandwich']
1919

2020
return (
21-
<HomeItem to="/bar">
21+
<HomeItem to="/bar/">
2222
<ResponsiveBar
2323
data={data}
2424
indexBy="country"

‎website/src/components/home/HomeCalendar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const calendarData = generateDayCounts(calendarFrom, calendarTo)
99

1010
const HomeCalendar = ({ colors, nivoTheme }) => {
1111
return (
12-
<HomeItem to="/calendar">
12+
<HomeItem to="/calendar/">
1313
<ResponsiveCalendarCanvas
1414
margin={{ top: 20, right: 2, bottom: 2, left: 20 }}
1515
from={calendarFrom}

‎website/src/components/home/HomeChord.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomeChord = ({ colors }) => {
77
return (
8-
<HomeItem to="/chord">
8+
<HomeItem to="/chord/">
99
<ResponsiveChordCanvas
1010
colors={colors}
1111
padAngle={0.04}

‎website/src/components/home/HomeCirclePacking.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
export const HomeCirclePacking = ({ reversedColors }) => {
77
return (
8-
<HomeItem to="/circle-packing">
8+
<HomeItem to="/circle-packing/">
99
<ResponsiveCirclePackingCanvas
1010
data={generateLibTree()}
1111
id="name"

‎website/src/components/home/HomeLine.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { commonAxes } from './settings'
66

77
const HomeLine = ({ colors, theme, nivoTheme }) => {
88
return (
9-
<HomeItem to="/line">
9+
<HomeItem to="/line/">
1010
<ResponsiveLine
1111
margin={{ top: 10, bottom: 15, left: 24, right: 10 }}
1212
data={generateDrinkStats(12)}

‎website/src/components/home/HomePie.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomePie = ({ colors, nivoTheme }) => {
77
return (
8-
<HomeItem to="/pie">
8+
<HomeItem to="/pie/">
99
<ResponsivePie
1010
margin={{
1111
top: 26,

‎website/src/components/home/HomeRadar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomeRadar = ({ colors, nivoTheme }) => {
77
return (
8-
<HomeItem to="/radar">
8+
<HomeItem to="/radar/">
99
<ResponsiveRadar
1010
{...generateWinesTastes()}
1111
indexBy="taste"

‎website/src/components/home/HomeSankey.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomeSankey = ({ colors, nivoTheme }) => {
77
return (
8-
<HomeItem to="/sankey">
8+
<HomeItem to="/sankey/">
99
<ResponsiveSankey
1010
margin={{ top: 0, right: 0, bottom: 0, left: 0 }}
1111
data={generateSankeyData({ nodeCount: 11, maxIterations: 2 })}

‎website/src/components/home/HomeStream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const generateStreamData = () =>
1616

1717
const HomeStream = ({ reversedColors, nivoTheme }) => {
1818
return (
19-
<HomeItem to="/stream">
19+
<HomeItem to="/stream/">
2020
<ResponsiveStream
2121
data={generateStreamData()}
2222
keys={range(streamDataLayerCount)}

‎website/src/components/home/HomeSunburst.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomeSunburst = ({ colors }) => {
77
return (
8-
<HomeItem to="/sunburst">
8+
<HomeItem to="/sunburst/">
99
<ResponsiveSunburst
1010
data={generateLibTree()}
1111
identity="name"

‎website/src/components/home/HomeSwarmPlot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const HomeSwarmPlot = ({ reversedColors, nivoTheme }) => {
77
const data = generateSwarmPlotData(['thing'], { min: 50, max: 50 })
88

99
return (
10-
<HomeItem to="/swarmplot">
10+
<HomeItem to="/swarmplot/">
1111
<ResponsiveSwarmPlotCanvas
1212
data={data.data}
1313
groups={data.groups}

‎website/src/components/home/HomeTreeMap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeItem, HomeItemLabel } from './styled'
55

66
const HomeTreeMap = ({ colors, nivoTheme }) => {
77
return (
8-
<HomeItem to="/treemap">
8+
<HomeItem to="/treemap/">
99
<ResponsiveTreeMapCanvas
1010
margin={{ top: 0, right: 0, bottom: 0, left: 0 }}
1111
data={generateLibTree()}

‎website/src/components/home/HomeVoronoi.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ voronoi.data = range(80).map(id => ({
1515

1616
const HomeVoronoi = ({ colors }) => {
1717
return (
18-
<HomeItem to="/voronoi">
18+
<HomeItem to="/voronoi/">
1919
<ResponsiveVoronoi
2020
data={voronoi.data}
2121
xDomain={voronoi.xDomain}

‎website/src/data/nav.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -374,26 +374,26 @@ export const allComponents = sortBy(all, 'label')
374374
export const guides = [
375375
{
376376
label: 'Axes',
377-
path: '/guides/axes',
377+
path: '/guides/axes/',
378378
},
379379
{
380380
label: 'Colors',
381-
path: '/guides/colors',
381+
path: '/guides/colors/',
382382
},
383383
{
384384
label: 'Legends',
385-
path: '/guides/legends',
385+
path: '/guides/legends/',
386386
},
387387
{
388388
label: 'Gradients',
389-
path: '/guides/gradients',
389+
path: '/guides/gradients/',
390390
},
391391
{
392392
label: 'Patterns',
393-
path: '/guides/patterns',
393+
path: '/guides/patterns/',
394394
},
395395
{
396396
label: 'Theming',
397-
path: '/guides/theming',
397+
path: '/guides/theming/',
398398
},
399399
]

‎website/src/pages/about.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ const About = () => {
4646
<li>Exhaustive documentation</li>
4747
<li>Isomorphic rendering</li>
4848
<li>
49-
<Link to="/components?filter=svg">SVG charts</Link>
49+
<Link to="/components/?filter=svg">SVG charts</Link>
5050
</li>
5151
<li>
52-
<Link to="/components?filter=html">HTML charts</Link>
52+
<Link to="/components/?filter=html">HTML charts</Link>
5353
</li>
5454
<li>
55-
<Link to="/components?filter=canvas">Canvas charts</Link>
55+
<Link to="/components/?filter=canvas">Canvas charts</Link>
5656
</li>
5757
<li>
5858
<a
@@ -64,16 +64,16 @@ const About = () => {
6464
</a>
6565
</li>
6666
<li>
67-
<Link to="/guides/legends">Legends</Link>
67+
<Link to="/guides/legends/">Legends</Link>
6868
</li>
6969
<li>
7070
<Link to="/guides/annotations">Annotations</Link>
7171
</li>
7272
<li>
73-
<Link to="/guides/patterns">SVG patterns</Link>
73+
<Link to="/guides/patterns/">SVG patterns</Link>
7474
</li>
7575
<li>
76-
<Link to="/guides/gradients">Gradients</Link>
76+
<Link to="/guides/gradients/">Gradients</Link>
7777
</li>
7878
<li>Responsive charts</li>
7979
</ul>

‎website/src/pages/faq.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const Faq = () => (
2525
Yes, sure! nivo was built with this requirement in mind from the very beginning,
2626
you even have an HTTP rendering API for most components :)
2727
<br />
28-
Just make sure to use <Link to="/components?filter=svg">SVG</Link> or{' '}
29-
<Link to="/components?filter=html">HTML</Link> implementations.
28+
Just make sure to use <Link to="/components/?filter=svg">SVG</Link> or{' '}
29+
<Link to="/components/?filter=html">HTML</Link> implementations.
3030
</p>
3131
<h4>Can I use nivo with very large data set?</h4>
3232
<p>
3333
Yes you can! SVG/HTML do not perform well when dealing with thousands of nodes,
3434
that's why you have some{' '}
35-
<Link to="/components?filter=canvas">canvas based implementations</Link> which
35+
<Link to="/components/?filter=canvas">canvas based implementations</Link> which
3636
are able to handle larger quantities of data.
3737
</p>
3838
<h4>My component isn't rendering</h4>

0 commit comments

Comments
 (0)
Please sign in to comment.