From 7ed7ea18fad5483d665a544eaa1cf779aed6b77c Mon Sep 17 00:00:00 2001 From: Juaco <37385297+jasanchez1@users.noreply.github.com> Date: Wed, 29 May 2024 12:08:55 +0100 Subject: [PATCH] feat: add optional location attribute (#30) * feat: add optional location attribute * chore: bump version to 0.1.1 --- README.md | 1 + package.json | 2 +- src/index.ts | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf88270..340672e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index 74e0e4f..44dd73f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 28d3708..5687604 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,6 +70,9 @@ interface Auction { category?: { id: string; }; + geoTargeting?: { + location: string; + }; searchQuery?: string; } @@ -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", @@ -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`), {