Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add multicategory query support #39

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ 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 |

\* Only one of `[category-id, category-ids, category-disjunctions]` must be set.
If multiple are set, only the first will be considered, in that order.

# 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) {
PabloReszczynski marked this conversation as resolved.
Show resolved Hide resolved
auction.category = {
ids: this.categoryIds.split(",").map((item) => item.trim()),
};
} else if (this.categoryDisjunctions) {
auction.category = {
disjunctions: [this.categoryDisjunctions.split(",").map((item) => item.trim())],
};
} else if (this.searchQuery) {
auction.searchQuery = this.searchQuery;
}
Expand Down