-
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
Conversation
f9c3851
to
33d524d
Compare
6666b3e
to
76e0463
Compare
a6a67c4
to
e31c523
Compare
6673b9e
to
3117dd2
Compare
3117dd2
to
c8eb8b1
Compare
// 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}`) | ||
) { |
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.
I might be missing something but it feels like you could do: selectedRoutes.includes(this.category.path)
and remove a lot of logic of this codeblock.
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.
I'll give that a shot! No reason, I just wanted to make it as specific as possible just in case.
@jjaffeux I think the edit would be a breaking change for a lot of people, after trying it out. The difference would be that people need the exact syntax of the path, for ex: |
I see thanks for trying |
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.
Looks good to me too, thanks Benji!
### Blocks from other plugins | ||
|
||
The Discourse Calendar plugin comes with a block called `upcoming-events-list` that you can use in conjunction with this component. You'll want to ensure the desired route is enabled via the `events calendar categories` setting in the Calendar plugin settings. The block params use this [syntax](https://momentjs.com/docs/#/displaying/format/), for example `MMMM D, YYYY`. |
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.
Allows component to handle subcategories.
In order for this to work with
upcoming-events-list
, you must add the subcategory to the Calendar plugin settings:(This started as a Sailpoint request, and from what I've seen on Meta it looks like others might utilize this as well.)