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

Make sure linting passes

This commit is contained in:
Tim Neutkens 2017-10-31 08:58:00 +01:00
parent 53a2c5a7fc
commit c8059b9f12
4 changed files with 20 additions and 21 deletions

View file

@ -1,18 +1,18 @@
import { withRouter } from 'next/router';
import Link from 'next/link';
import React, { Children } from 'react';
import { withRouter } from 'next/router'
import Link from 'next/link'
import React, { Children } from 'react'
const ActiveLink = ({ router, children, ...props }) => {
const child = Children.only(children);
const child = Children.only(children)
let className = child.props.className || '';
let className = child.props.className || ''
if (router.pathname === props.href && props.activeClassName) {
className = `${className} ${props.activeClassName}`.trim();
className = `${className} ${props.activeClassName}`.trim()
}
delete props.activeClassName;
delete props.activeClassName
return <Link {...props}>{React.cloneElement(child, { className })}</Link>;
};
return <Link {...props}>{React.cloneElement(child, { className })}</Link>
}
export default withRouter(ActiveLink);
export default withRouter(ActiveLink)

View file

@ -1,5 +1,4 @@
import Link from './Link';
import Head from 'next/head';
import Link from './Link'
export default () => (
<nav>
@ -17,15 +16,15 @@ export default () => (
<ul>
<li>
<Link activeClassName="active" href="/">
<a className="nav-link home-link">Home</a>
<Link activeClassName='active' href='/'>
<a className='nav-link home-link'>Home</a>
</Link>
</li>
<li>
<Link activeClassName="active" href="/about">
<a className="nav-link">About</a>
<Link activeClassName='active' href='/about'>
<a className='nav-link'>About</a>
</Link>
</li>
</ul>
</nav>
);
)

View file

@ -1,8 +1,8 @@
import Nav from '../components/Nav';
import Nav from '../components/Nav'
export default () => (
<div>
<Nav />
<p>Hello, I'm About.js</p>
</div>
);
)

View file

@ -1,8 +1,8 @@
import Nav from '../components/Nav';
import Nav from '../components/Nav'
export default () => (
<div>
<Nav />
<p>Hello, I'm the home page</p>
</div>
);
)