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 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
0
src/constants/routes.js
Normal file
Loading…
Reference in a new issue