-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: Support subcategory paths in custom route setting #60
Changes from all commits
33d524d
76e0463
e31c523
fd93677
fe97949
021829b
c8eb8b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,20 +8,37 @@ export default { | |
|
||
@discourseComputed( | ||
"router.currentRouteName", | ||
"router.currentRoute.attributes.category", | ||
"router.currentRoute.attributes.category.slug", | ||
"router.currentRoute.attributes.tag.id" | ||
) | ||
showSidebar(currentRouteName, categorySlug, tagId) { | ||
showSidebar(currentRouteName, category, categorySlug, tagId) { | ||
if (this.site.mobileView) { | ||
return false; | ||
} | ||
|
||
if (settings.show_in_routes !== "") { | ||
const selectedRoutes = settings.show_in_routes.split("|"); | ||
let subcategory = null; | ||
let parentCategory = null; | ||
|
||
// check if current page is subcategory | ||
// -- is category | ||
// -- does not have children itself | ||
// -- has a parent category | ||
if ( | ||
!!this.category && | ||
!this.category.has_children && | ||
!!this.category.parent_category_id | ||
) { | ||
subcategory = categorySlug; | ||
parentCategory = category.ancestors[0].slug; | ||
} | ||
|
||
if ( | ||
selectedRoutes.includes(currentRouteName) || | ||
selectedRoutes.includes(`c/${categorySlug}`) || | ||
selectedRoutes.includes(`c/${parentCategory}/${subcategory}`) || | ||
selectedRoutes.includes(`tag/${tagId}`) | ||
) { | ||
Comment on lines
+25
to
43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might be missing something but it feels like you could do: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll give that a shot! No reason, I just wanted to make it as specific as possible just in case. |
||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is neat to have in the readme. Other plugins/themes contribute blocks that can be used here, I can think of just Gamification off the top of my head, but I'm sure there are a few more. Probably documented on the meta topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh cool! Good to know.