This commit is contained in:
@@ -3,6 +3,7 @@ import { Link, useLocation, useParams } from 'react-router-dom'
|
||||
import SettingsDialogue from './SettingsDialogue'
|
||||
import { Button } from './ui/button'
|
||||
import clsx from 'clsx'
|
||||
import { WikiIdBus } from '@/lib/eventBus/WikiIdBus'
|
||||
|
||||
import type { User } from '@/types'
|
||||
|
||||
@@ -21,6 +22,7 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
||||
|
||||
const [settingsVisible, setSettingsVisible] = useState (false)
|
||||
const [selectedMenu, setSelectedMenu] = useState<Menu> (Menu.None)
|
||||
const [wikiId, setWikiId] = useState (WikiIdBus.get ())
|
||||
|
||||
const MyLink = ({ to, title, menu, base }: { to: string
|
||||
title: string
|
||||
@@ -33,6 +35,8 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
||||
{title}
|
||||
</Link>)
|
||||
|
||||
useEffect (() => WikiIdBus.subscribe (setWikiId), [])
|
||||
|
||||
useEffect (() => {
|
||||
if (location.pathname.startsWith ('/posts'))
|
||||
setSelectedMenu (Menu.Post)
|
||||
@@ -90,8 +94,8 @@ const TopNav: React.FC = ({ user, setUser }: Props) => {
|
||||
<>
|
||||
<Separator />
|
||||
<Link to={`/posts?tags=${ location.pathname.split ('/')[2] }`} className={subClass}>投稿</Link>
|
||||
<Link to={`/wiki/${ location.pathname.split ('/')[2] }/history`} className={subClass}>履歴</Link>
|
||||
<Link to={`/wiki/${ location.pathname.split ('/')[2] }/edit`} className={subClass}>編輯</Link>
|
||||
<Link to={`/wiki/${ wikiId || location.pathname.split ('/')[2] }/history`} className={subClass}>履歴</Link>
|
||||
<Link to={`/wiki/${ wikiId || location.pathname.split ('/')[2] }/edit`} className={subClass}>編輯</Link>
|
||||
</>}
|
||||
</div>)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user