Skip to content

Commit

Permalink
Add multicategory query support
Browse files Browse the repository at this point in the history
  • Loading branch information
anonvt committed Jun 26, 2024
1 parent d238f52 commit 6b70908
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ interface Auction {
device: "mobile" | "desktop";
slotId: string;
category?: {
id: string;
id?: string;
ids?: string[];
disjunctions?: string[];
};
geoTargeting?: {
location: string;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6b70908

Please sign in to comment.