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:
parent
53a2c5a7fc
commit
c8059b9f12
|
@ -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)
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
)
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
)
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue