Skip to content

Commit

Permalink
conditionally check for slug
Browse files Browse the repository at this point in the history
  • Loading branch information
EndangeredMassa committed Sep 20, 2023
1 parent 6ff4f15 commit 919d71f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/routes/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ import articles from '../article-data';
export default class ArticlesArticleRoute extends Route {
beforeModel(transition) {
// set the proper template
let slug = transition.intent.url.replace('/articles/', '');

let slug;
if (transition.intent.url) {
// direct load
slug = transition.intent.url.replace('/articles/', '');
} else {
// linked load
slug = transition.routeInfos[1].context.slug;
}

this.templateName = `articles.${slug}`;
}

Expand Down

0 comments on commit 919d71f

Please sign in to comment.