Skip to content

Commit

Permalink
feat(news): consider priority flag to sort on home carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsandoz committed Apr 29, 2024
1 parent 9a0db80 commit 70b9515
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/cms-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,14 @@ const cmsService: Plugin = (context, inject) => {
})
);

const sort: Query<DirectusSchema, DirectusNews>['sort'] = [];

if (forHomepage) {
sort.push('-prioritise_on_home');
}

sort.push('-date_created');

const newsResponse = await context.$directus.request<DirectusNews[]>(
readItems('news', {
limit,
Expand All @@ -561,7 +569,7 @@ const cmsService: Plugin = (context, inject) => {
domains: [{ domains_id: ['id'] }],
},
],
sort: ['-date_created'],
sort,
})
);

Expand Down
1 change: 1 addition & 0 deletions plugins/directus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export interface DirectusNews {
id: number;
status: string;
hide_from_home: boolean;
prioritise_on_home: boolean;
date_created: 'datetime';
date_updated: 'datetime';
main_image: DirectusFile<DirectusSchema>;
Expand Down

0 comments on commit 70b9515

Please sign in to comment.