fix followed tag active tab highlighting
This commit is contained in:
parent
24b07e4a27
commit
d314f8269d
@ -40,8 +40,22 @@ export default function RootPage() {
|
|||||||
data: "/global",
|
data: "/global",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tagTabs = tags.item.map((t, idx) => {
|
||||||
|
return { text: `#${t}`, value: idx + 3, data: `/tag/${t}` };
|
||||||
|
});
|
||||||
|
const tabs = [RootTab.Posts, RootTab.PostsAndReplies, RootTab.Global, ...tagTabs];
|
||||||
const tab = useMemo(() => {
|
const tab = useMemo(() => {
|
||||||
const pTab = location.pathname.split("/").slice(-1)[0];
|
const pTab = location.pathname.split("/").slice(-1)[0];
|
||||||
|
|
||||||
|
if (location.pathname.startsWith("/tag")) {
|
||||||
|
const selectedTag = tagTabs.find(t => t.text.slice(1) === pTab);
|
||||||
|
|
||||||
|
if (selectedTag) {
|
||||||
|
return selectedTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (pTab) {
|
switch (pTab) {
|
||||||
case "conversations": {
|
case "conversations": {
|
||||||
return RootTab.PostsAndReplies;
|
return RootTab.PostsAndReplies;
|
||||||
@ -64,11 +78,6 @@ export default function RootPage() {
|
|||||||
}
|
}
|
||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
const tagTabs = tags.item.map((t, idx) => {
|
|
||||||
return { text: `#${t}`, value: idx + 3, data: `/tag/${t}` };
|
|
||||||
});
|
|
||||||
const tabs = [RootTab.Posts, RootTab.PostsAndReplies, RootTab.Global, ...tagTabs];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="main-content">
|
<div className="main-content">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user