components/Layout.js
import React, { Component } from 'react';
import Header from '../components/Header';
import Footer from '../components/Footer';
import style from '../static/Style';
class Layout extends Component {
render() {
return (<div>
{style}
<Header header={this.props.header}
title={this.props.title} />
{this.props.children}
<Footer footer="copyright hogehoge."/>
</div>)
}
}
export default Layout;
components/Header.js
import React, {Component} from 'react';
class Header extends Component {
render() {
return (<header>
<div>{this.props.header}</div>
<h1>{this.props.title}</h1>
</header>)
}
}
export default Header;
components/Footer.js
import React, {Component} from 'react';
class Footer extends Component {
render() {
return (<footer>
<div>{this.props.footer}</div>
</footer>)
}
}
export default Footer;
static/Style.js
export default <style>{`
body {
margin:10px;
padding: 5px;
color: #669;
}
header {
font-size: 64pt;
font-weight: bold;
text-align:right;
letter-spacing: -8px;
color: #ddddff;
margin: -32px 5px;
}
footer {
color:#99c;
font-size:12pt;
text-align:right;
border-bottom:1px solid #99c;
margin: 50px 0px 10px 0px;
position: relative;
bottom: 10px;
right: 10px;
left: 10px;
}
h1 {
font-size:68pt;
font-weight:bold;
text-align:right;
letter-spacing:-8px;
color:#f0f0f0;
margin:-32px 0px;
}
p {
margin:0px;
color:#666;
font-size:16pt;
}
`}</style>
index.js
import Link from 'next/link';
import Layout from '../components/Layout';
export default () => (
<Layout header="Next" title="Top page.">
<p>Welcome to next.js!</p>
<hr />
<Link href="./other">
<button>go to Other >></button>
</Link>
</Layout>
);
other.js
import Link from 'next/link';
import Layout from '../components/Layout';
export default () => (
<Layout header="Other" title="Other page.">
<p>This is other page.</p>
<hr />
<Link href="./">
<button><< Back to Top</button>
</Link>
</Layout>
);


import React, { Component } from 'react';
class Image extends Component {
constructor(props) {
super(props);
this.fname = "./static/" + props.fname;
this.size = props.size + "px";
}
render() {
return (
<img width={this.size} border="1"
src={this.fname} />
);
}
}
export default Image;

なるほど、面白いと言えば面白い。