Skip to content

Commit

Permalink
Merge pull request #810 from prezly/feature/care-6528-add-filter-by-tag
Browse files Browse the repository at this point in the history
…_names-to-stories-api-in-theme-kit

[CARE-6528] Feature - Add filter by tag_names to stories API in theme-kit
  • Loading branch information
fgyimah authored Nov 4, 2024
2 parents 83f75f3 + 0536a7a commit 3749348
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 3749348

Please sign in to comment.