create basic routing

This commit is contained in:
horhik 2020-05-25 02:59:57 +03:00
parent c5d14c2835
commit 8ebb646352
3 changed files with 25 additions and 11 deletions

View file

View file

@ -1,22 +1,36 @@
import React from 'react' import React from 'react'
import asciiWord from "../../functions/ascii-word"; import asciiWord from "../../functions/ascii-word";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import pages from "../../constants/routes";
import {connect} from 'react-redux'
import {setCurrentPage} from "../../actions/route-actions";
const PageLinks = props => { const PageLinks = props => {
const goToPage = page => {
props.setCurrentPage(page)
}
return( return(
<ul className={'page-list'}> <ul className={'page-list'}>
<li className={'page-link'}> {
<Link to={'/portfolio'}> pages.map(page => {
{asciiWord('Portfolio')} if(page.src !== props.currentPageSrc){
</Link> return(
</li>
<li className={'page-link'}> <li key={page.src} className={'page-link'}>
<Link to={'/blog'}> <Link to={page.src} onClick={() => goToPage(page)}>
{asciiWord('Blog')} {asciiWord(page.name)}
</Link> </Link>
</li> </li>
)
}
})
}
</ul> </ul>
) )
} }
export default PageLinks export default connect(state => ({
currentPageSrc: state.client.currentPath
}), {
setCurrentPage
})(PageLinks)

0
src/constants/routes.js Normal file
View file