Skip to content

Commit 8dde6ce

Browse files
committed
Add static routing
1 parent 9b5c97c commit 8dde6ce

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
npm-debug.log
2+
dist
33
.DS_STORE
44
*.swp
5-
tmp

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Documentation for Tachyons -- a performant, mobile-first, and 100% responsive modular css framework.",
66
"scripts": {
77
"start": "x0 dev src/App.js -o",
8-
"build": "x0 build src/App.js",
8+
"build": "x0 build src/App.js -sd dist",
99
"prepare": "node modules"
1010
},
1111
"repository": "tachyons-css/docs",
@@ -101,5 +101,12 @@
101101
],
102102
"devDependencies": {
103103
"@compositor/x0": "^3.0.2"
104+
},
105+
"x0": {
106+
"routes": [
107+
"/",
108+
"/docs",
109+
"/docs/table-of-styles"
110+
]
104111
}
105112
}

src/App.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import React from 'react'
22

33
import {
4-
BrowserRouter as Router,
4+
BrowserRouter,
5+
StaticRouter,
56
Route
67
} from 'react-router-dom'
78

9+
const Router = typeof document === 'undefined' ? StaticRouter : BrowserRouter
10+
811
import withData from './withData'
912
import Layout from './Layout'
1013
import Home from './Home'
1114
import Docs from './Docs'
1215

1316
const App = props =>
14-
<Router>
17+
<Router location={props.pathname}>
1518
<Layout {...props}>
1619
<Route exact path='/' component={withData(Home)} />
17-
<Route path='/docs' component={Docs} />
20+
<Route path='/docs' component={withData(Docs)} />
1821
</Layout>
1922
</Router>
2023

21-
export default App
24+
export default withData(App)

src/Layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import Header from './Header'
44
import Footer from './Footer'
55

66
export default ({
7-
title = 'Tachyons - Css Toolkit',
7+
title = 'TACHYONS - Css Toolkit',
88
version,
99
children
1010
}) =>
1111
<div className='w-100 sans-serif'>
1212
<title>{title}</title>
1313
<link
1414
rel='stylesheet'
15-
href={`https://unpkg.com/tachyons/css/tachyons.min.css`}
15+
href='https://unpkg.com/tachyons/css/tachyons.min.css'
1616
/>
1717

1818
<Header version={version} />

src/withData.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import data from '../data.json'
55

66
export default Component => props =>
77
<Component
8-
version={version}
98
{...props}
109
{...data}
10+
version={version}
1111
/>

0 commit comments

Comments
 (0)