Sto usando router e discovery per creare un hero dinamico a seconda della pagina visualizzata, tuttavia quando arrivo a una pagina di argomento individuale non riesco a trovare un modo per passare il titolo dell’argomento al template.
C’è un modo per recuperare il titolo dell’argomento qui?
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { defaultHomepage } from "discourse/lib/utilities";
export default class BcnHero extends Component {
@service router;
@service discovery;
get showHero() {
const { currentRouteName } = this.router;
const { category } = this.discovery;
let categoryName = "";
let categoryDescription = "";
if (category) {
categoryName = category.name;
categoryDescription = category.description;
}
if (currentRouteName === `discovery.${defaultHomepage()}`) {
return { homepageHero: true };
}
if (currentRouteName === "discovery.category" || currentRouteName.startsWith("topic")) {
return { dynamicHero: true, title: categoryName, subtitle: categoryDescription };
}
return { emptyHero: true };
}
}