From 6b709084467c6743f13aed0f6fb89f3cf303f360 Mon Sep 17 00:00:00 2001 From: Guilherme Pimenta Date: Wed, 26 Jun 2024 18:19:37 -0300 Subject: [PATCH] Add multicategory query support --- README.md | 18 ++++++++++-------- src/index.ts | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bf9f510..17259be 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,16 @@ Directly from unpkg.com # Banner Attributes -| Name | Type | Description | -| ------------ | --------------- | ------------------------------------ | -| width | Number | Banner width | -| height | Number | Banner height | -| id | String | The slot ID for this banner | -| category-id | Optional String | The category ID of the current page | -| search-query | Optional String | The search query of the current page | -| location | Optional String | The location for geotargeting | +| Name | Type | Description | +| ---------------------- | --------------- | ------------------------------------------------------------------ | +| width | Number | Banner width | +| height | Number | Banner height | +| id | String | The slot ID for this banner | +| category-id | Optional String | The category ID of the current page | +| category-ids | Optional String | Comma (,) separated list of category IDs, the item must match all | +| category-disjunctions | Optional String | Comma (,) separated list of category IDs, the item must match any | +| search-query | Optional String | The search query of the current page | +| location | Optional String | The location for geotargeting | # Banner Behaviors diff --git a/src/index.ts b/src/index.ts index aeac817..700d6c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -68,7 +68,9 @@ interface Auction { device: "mobile" | "desktop"; slotId: string; category?: { - id: string; + id?: string; + ids?: string[]; + disjunctions?: string[]; }; geoTargeting?: { location: string; @@ -103,6 +105,12 @@ export class TopsortBanner extends LitElement { @property({ attribute: "category-id", type: String }) readonly categoryId?: string; + @property({ attribute: "category-ids", type: String }) + readonly categoryIds?: string; + + @property({ attribute: "category-disjunctions", type: String }) + readonly categoryDisjunctions?: string; + @property({ attribute: "search-query", type: String }) readonly searchQuery?: string; @@ -198,6 +206,14 @@ export class TopsortBanner extends LitElement { auction.category = { id: this.categoryId, }; + } else if (this.categoryIds) { + auction.category = { + ids: this.categoryIds.split(","), + }; + } else if (this.categoryDisjunctions) { + auction.category = { + disjunctions: this.categoryDisjunctions.split(","), + }; } else if (this.searchQuery) { auction.searchQuery = this.searchQuery; }