update: dynamic indexer

This commit is contained in:
srgooglo 2020-09-08 14:51:56 +02:00
parent 0316c55374
commit acbe2adf34

36
src/pages/[page].js Normal file
View File

@ -0,0 +1,36 @@
import React, { PureComponent } from 'react'
import { pathMatchRegexp } from 'core'
import Error404 from './404.js'
// <UserProfile {...this.props} regx={matchUser} />
class PageIndexer extends PureComponent {
render() {
const { location } = this.props
const matchUser = pathMatchRegexp('/@:id', location.pathname)
const matchSetting = pathMatchRegexp('/~:id', location.pathname)
console.log(matchSetting)
if (matchUser) {
return (
<div>
User, matched => {matchUser}
</div>
)
}
if (matchSetting) {
return(
<div>
Bruh, matched => {matchSetting}
</div>
)
}
// By default return Error 404
return (
<div>
<Error404 />
</div>
)
}
}
export default PageIndexer