Skip to content

Commit

Permalink
move articles under blog for active link support
Browse files Browse the repository at this point in the history
  • Loading branch information
EndangeredMassa committed Jan 15, 2024
1 parent bc5a4c7 commit 19bdbec
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/components/article-card.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LinkTo } from '@ember/routing';
<div class="blog-item">
<h2>
<LinkTo class="post-link"
@route="article"
@route="blog.article"
@model={{@article}}>
{{@article.title}}
</LinkTo>
Expand Down
3 changes: 1 addition & 2 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Router.map(function () {
})

this.route('blog', function() {
this.route('article', { path: '/:slug' });
this.route('index', { path: '/' });
});

this.route('article', { path: '/blog/:slug' });
});
6 changes: 3 additions & 3 deletions app/routes/article.js → app/routes/blog/article.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Route from '@ember/routing/route';
import articles from '../article-data';
import articles from '../../article-data';

export default class BlogRoute extends Route {
beforeModel(transition) {
Expand All @@ -11,13 +11,13 @@ export default class BlogRoute extends Route {
slug = transition.intent.url.replace('/blog/', '');
} else {
// linked load
const info = transition.routeInfos[1];
const info = transition.routeInfos[2];

slug = info?.context?.slug || info?.params?.slug;
}

if (slug) {
this.templateName = `article.${slug}`;
this.templateName = `blog.article.${slug}`;
}
}

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/templates/blog.gjs → app/templates/blog/index.gjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import RouteTemplate from 'ember-route-template';
import ArticleCard from '../components/article-card';
import articles from '../article-data';
import ArticleCard from '../../components/article-card';
import articles from '../../article-data';

export default RouteTemplate(
<template>
Expand Down

0 comments on commit 19bdbec

Please sign in to comment.