Set content based on URL
This commit is contained in:
parent
660ad41d4e
commit
6aba8d29ea
2 changed files with 31 additions and 11 deletions
|
|
@ -27,6 +27,14 @@ module.exports = {
|
||||||
source: '/weapons',
|
source: '/weapons',
|
||||||
destination: '/new',
|
destination: '/new',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
source: '/updates',
|
||||||
|
destination: '/about',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
source: '/roadmap',
|
||||||
|
destination: '/about',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
source: '/p/:shortcode/characters',
|
source: '/p/:shortcode/characters',
|
||||||
destination: '/p/:shortcode',
|
destination: '/p/:shortcode',
|
||||||
|
|
|
||||||
|
|
@ -29,25 +29,37 @@ const AboutRoute: React.FC<Props> = (props: Props) => {
|
||||||
|
|
||||||
const [currentTab, setCurrentTab] = useState<AboutTabs>(AboutTabs.About)
|
const [currentTab, setCurrentTab] = useState<AboutTabs>(AboutTabs.About)
|
||||||
|
|
||||||
function handleTabClicked(event: React.ChangeEvent<HTMLInputElement>) {
|
useEffect(() => {
|
||||||
const path = [
|
const parts = router.asPath.split('/')
|
||||||
router.asPath.split('/').filter((el) => el != '')[1],
|
const tab = parts[parts.length - 1]
|
||||||
event.target.value,
|
|
||||||
].join('/')
|
|
||||||
|
|
||||||
// TODO: Decide if we want /about/changlog or /changelog
|
switch (tab) {
|
||||||
// TODO: Then, set up Next.js rewrites
|
|
||||||
switch (event.target.value) {
|
|
||||||
case 'about':
|
case 'about':
|
||||||
// router.replace(path)
|
|
||||||
setCurrentTab(AboutTabs.About)
|
setCurrentTab(AboutTabs.About)
|
||||||
break
|
break
|
||||||
case 'updates':
|
case 'updates':
|
||||||
// router.replace(path)
|
|
||||||
setCurrentTab(AboutTabs.Updates)
|
setCurrentTab(AboutTabs.Updates)
|
||||||
break
|
break
|
||||||
case 'roadmap':
|
case 'roadmap':
|
||||||
// router.replace(path)
|
setCurrentTab(AboutTabs.Roadmap)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}, [router.asPath])
|
||||||
|
|
||||||
|
function handleTabClicked(event: React.ChangeEvent<HTMLInputElement>) {
|
||||||
|
const path = `/${event.target.value}`
|
||||||
|
|
||||||
|
switch (event.target.value) {
|
||||||
|
case 'about':
|
||||||
|
router.replace(path)
|
||||||
|
setCurrentTab(AboutTabs.About)
|
||||||
|
break
|
||||||
|
case 'updates':
|
||||||
|
router.replace(path)
|
||||||
|
setCurrentTab(AboutTabs.Updates)
|
||||||
|
break
|
||||||
|
case 'roadmap':
|
||||||
|
router.replace(path)
|
||||||
setCurrentTab(AboutTabs.Roadmap)
|
setCurrentTab(AboutTabs.Roadmap)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue