mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
only make the selected tag active
This commit is contained in:
@@ -104,13 +104,19 @@ class SideNav extends React.Component {
|
|||||||
<TagListItem
|
<TagListItem
|
||||||
name={tag}
|
name={tag}
|
||||||
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
|
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
|
||||||
isActive={!!location.pathname.match(tag)}
|
isActive={this.getTagActive(location.pathname, tag)}
|
||||||
key={tag}
|
key={tag}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTagActive (path, tag) {
|
||||||
|
const pathSegments = path.split('/')
|
||||||
|
const pathTag = pathSegments[pathSegments.length - 1]
|
||||||
|
return pathTag === tag
|
||||||
|
}
|
||||||
|
|
||||||
handleClickTagListItem (name) {
|
handleClickTagListItem (name) {
|
||||||
const { router } = this.context
|
const { router } = this.context
|
||||||
router.push(`/tags/${name}`)
|
router.push(`/tags/${name}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user