From 919d71f324c2902c10bad53c3c2dc26f2f89fb79 Mon Sep 17 00:00:00 2001 From: Sean Massa Date: Wed, 20 Sep 2023 01:39:49 -0500 Subject: [PATCH] conditionally check for slug --- app/routes/article.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/routes/article.js b/app/routes/article.js index 3070a09..c4c8980 100644 --- a/app/routes/article.js +++ b/app/routes/article.js @@ -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}`; }