mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
Support appending a category id to a navigation item dynamically
This commit is contained in:
parent
422f990615
commit
882cc9f992
@ -16,7 +16,18 @@ export default Ember.Component.extend(bufferedRender({
|
||||
|
||||
buildBuffer(buffer) {
|
||||
const content = this.get('content');
|
||||
buffer.push("<a href='" + content.get('href') + "'>");
|
||||
|
||||
let href = content.get('href');
|
||||
|
||||
// Include the category id if the option is present
|
||||
if (content.get('includeCategoryId')) {
|
||||
let categoryId = this.get('category.id');
|
||||
if (categoryId) {
|
||||
href += `?category_id=${categoryId}`;
|
||||
}
|
||||
}
|
||||
|
||||
buffer.push(`<a href='${href}'>`);
|
||||
if (content.get('hasIcon')) {
|
||||
buffer.push("<span class='" + content.get('name') + "'></span>");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
{{#each navItems as |navItem|}}
|
||||
{{navigation-item content=navItem filterMode=filterMode}}
|
||||
{{navigation-item content=navItem filterMode=filterMode category=category}}
|
||||
{{/each}}
|
||||
{{custom-html name="extraNavItem" tagName="li"}}
|
||||
{{!- this is done to avoid DIV in the UL, originally {{plugin-outlet name="extra-nav-item"}}
|
||||
|
@ -7,7 +7,7 @@
|
||||
{{#if expanded}}
|
||||
<ul class='drop'>
|
||||
{{#each navItems as |navItem|}}
|
||||
{{navigation-item content=navItem filterMode=filterMode}}
|
||||
{{navigation-item content=navItem filterMode=filterMode category=category}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user