1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Added the test app for static export.

This commit is contained in:
Arunoda Susiripala 2017-05-09 14:03:20 -07:00
parent 450277f294
commit e8ff53f519
6 changed files with 130 additions and 0 deletions

2
.gitignore vendored
View file

@ -12,4 +12,6 @@ npm-debug.log
.nyc_output
coverage
# test output
test/**/.out
.DS_Store

View file

@ -0,0 +1,12 @@
module.exports = {
exportPathMap: function () {
return {
'/': { page: '/' },
'/about': { page: '/about' },
'/counter': { page: '/counter' },
'/dynamic': { page: '/dynamic', query: { text: 'cool dynamic text' } },
'/dynamic/one': { page: '/dynamic', query: { text: 'next export is nice' } },
'/dynamic/two': { page: '/dynamic', query: { text: 'zeit is awesome' } }
}
}
}

View file

@ -0,0 +1,12 @@
import Link from 'next/link'
export default () => (
<div id='about-page'>
<div>
<Link href='/'>
<a>Go Back</a>
</Link>
</div>
<p>This is the About page</p>
</div>
)

View file

@ -0,0 +1,33 @@
import React from 'react'
import Link from 'next/link'
export default class Counter extends React.Component {
constructor (...args) {
super(...args)
this.state = { count: 0 }
}
increaseCounter () {
const { count } = this.state
this.setState({ count: count + 1 })
}
render () {
const { count } = this.state
return (
<div id='counter-page'>
<div>
<Link href='/'>
<a>Go Back</a>
</Link>
</div>
<p>Counter: {count}</p>
<button
onClick={() => this.increaseCounter()}
>
Increase
</button>
</div>
)
}
}

View file

@ -0,0 +1,18 @@
import Link from 'next/link'
const DynamicPage = ({ text }) => (
<div id='about-page'>
<div>
<Link href='/'>
<a>Go Back</a>
</Link>
</div>
<p>{ text }</p>
</div>
)
DynamicPage.getInitialProps = ({ query }) => {
return { text: query.text }
}
export default DynamicPage

View file

@ -0,0 +1,53 @@
import Link from 'next/link'
import Router from 'next/router'
function routeToAbout (e) {
e.preventDefault()
Router.push('/about')
}
export default () => (
<div id='home-page'>
<div>
<Link href='/about' id='about-via-link'>
<a>About via Link</a>
</Link>
<a
href='#'
onClick={routeToAbout}
id='about-via-router'
>
About via Router
</a>
<Link href='/counter' id='counter'>
<a>Counter</a>
</Link>
<Link
href='/dynamic?text=cool+dynamic+text'
id='get-initial-props'
>
<a>getInitialProps</a>
</Link>
<Link
href='/dynamic?text=next+export+is+nice'
as='/dynamic/one'
id='dynamic-1'
>
<a>Dynamic 1</a>
</Link>
<Link
href='/dynamic?text=zeit+is+awesome'
as='/dynamic/two'
id='dynamic-2'
>
<a>Dynamic 2</a>
</Link>
</div>
<p>This is the home page</p>
<style jsx>{`
a {
margin: 0 10px 0 0;
}
`}</style>
</div>
)