FEATURE: Show topic title and category in site title (#25)

This commit is contained in:
Justin DiRose 2021-01-13 13:26:52 -06:00 committed by GitHub
parent 0d396f921e
commit a82db01108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -1,7 +1,8 @@
import Route from "@ember/routing/route";
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";
export default Route.extend({
export default DiscourseRoute.extend({
queryParams: {
ascending: { refreshModel: true },
filterCategories: { refreshModel: true },
@ -22,6 +23,20 @@ export default Route.extend({
});
},
titleToken() {
const model = this.currentModel;
const pageTitle = I18n.t("knowledge_explorer.title");
if (model.topic.title && model.topic.category_id) {
const categoryName = this.site.categories.findBy(
"id",
model.topic.category_id
).name;
return `${model.topic.unicode_title} - ${categoryName} - ${pageTitle}`;
} else {
return pageTitle;
}
},
setupController(controller, model) {
controller.set("topic", model.topic);
controller.set("model", model);

View File

@ -1,3 +1,3 @@
import Route from "@ember/routing/route";
import DiscourseRoute from "discourse/routes/discourse";
export default Route.extend({});
export default DiscourseRoute.extend({});