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 asciiWord from "../../functions/ascii-word";
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 goToPage = page => {
props.setCurrentPage(page)
}
return(
<ul className={'page-list'}>
<li className={'page-link'}>
<Link to={'/portfolio'}>
{asciiWord('Portfolio')}
</Link>
</li>
<li className={'page-link'}>
<Link to={'/blog'}>
{asciiWord('Blog')}
</Link>
</li>
{
pages.map(page => {
if(page.src !== props.currentPageSrc){
return(
<li key={page.src} className={'page-link'}>
<Link to={page.src} onClick={() => goToPage(page)}>
{asciiWord(page.name)}
</Link>
</li>
)
}
})
}
</ul>
)
}
export default PageLinks
export default connect(state => ({
currentPageSrc: state.client.currentPath
}), {
setCurrentPage
})(PageLinks)

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