Skip to content

Commit

Permalink
[CARE-6528] Added filter by tag_names to stories API
Browse files Browse the repository at this point in the history
  • Loading branch information
fgyimah committed Nov 4, 2024
1 parent 83f75f3 commit 0536a7a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/core/src/content-delivery/ContentDelivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export namespace stories {
export interface SearchParams {
search?: string;
category?: Pick<Category, 'id'>;
tags?: string[];
locale?: Pick<Culture, 'code'> | Culture.Code;
limit: number;
offset?: number;
Expand Down Expand Up @@ -237,7 +238,16 @@ export function createClient(
params: stories.SearchParams,
options: stories.IncludeOptions<Include> = {},
) {
const { search, query, offset = 0, limit, category, locale, highlighted = 0 } = params;
const {
search,
query,
offset = 0,
limit,
category,
locale,
highlighted = 0,
tags,
} = params;
const { include = [] } = options;

const localeCode = locale && typeof locale === 'object' ? locale.code : locale;
Expand All @@ -254,6 +264,7 @@ export function createClient(
[`locale`]: localeCode ? { $in: [localeCode] } : undefined,
[`status`]: { $in: [Story.Status.PUBLISHED] },
[`visibility`]: { $in: [Story.Visibility.PUBLIC] },
[`tag_names`]: tags?.length ? { $in: [tags] } : undefined,
}),
include,
});
Expand Down

0 comments on commit 0536a7a

Please sign in to comment.