Skip to content

Commit

Permalink
feat: add optional location attribute (#30)
Browse files Browse the repository at this point in the history
* feat: add optional location attribute

* chore: bump version to 0.1.1
  • Loading branch information
jasanchez1 authored May 29, 2024
1 parent 72d8841 commit 7ed7ea1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Directly from unpkg.com
| slot-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 |

# Banner Behaviors

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@topsort/banners",
"version": "0.1.0",
"version": "0.1.1",
"description": "A web component for displaying Topsort banner ads.",
"type": "module",
"author": "Topsort",
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ interface Auction {
category?: {
id: string;
};
geoTargeting?: {
location: string;
};
searchQuery?: string;
}

Expand Down Expand Up @@ -103,6 +106,9 @@ export class TopsortBanner extends LitElement {
@property({ attribute: "search-query", type: String })
readonly searchQuery?: string;

@property({ attribute: "location", type: String })
readonly location?: string;

@state()
private state: BannerState = {
status: "loading",
Expand Down Expand Up @@ -150,6 +156,11 @@ export class TopsortBanner extends LitElement {
} else if (this.searchQuery) {
auction.searchQuery = this.searchQuery;
}
if (this.location) {
auction.geoTargeting = {
location: this.location,
};
}
const token = window.TS.token;
const url = window.TS.url || "https://api.topsort.com";
const res = await fetch(new URL(`${url}/v2/auctions`), {
Expand Down

0 comments on commit 7ed7ea1

Please sign in to comment.