create basic routing
This commit is contained in:
parent
c5d14c2835
commit
8ebb646352
0
src/actions/route-actions.js
Normal file
0
src/actions/route-actions.js
Normal 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
0
src/constants/routes.js
Normal file
Loading…
Reference in a new issue