Skip to content

Commit afae0fc

Browse files
committed
feat: default hostname to current site
1 parent f3101de commit afae0fc

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

.changeset/moody-pandas-impress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@vnphanquang/green-check': patch
3+
---
4+
5+
default hostname to current site

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ loadGreenCheck();
5858

5959
## 3. Using the Custom Element
6060

61+
Use `<green-check>` where applicable with the `hostname` attribute as the host name of your
62+
site. If not provided `hostname` will default to `window.location.hostname`, i.e current site.
63+
6164
```html
6265
<green-check hostname="www.yourdomain.xyz">
6366
<img
@@ -74,7 +77,7 @@ loadGreenCheck();
7477
Colors of the badge can be customized by providing the following CSS custom properties (default values are shown):
7578

7679
```html
77-
<green-check>
80+
<green-check hostname="www.yourdomain.xyz">
7881
<!-- [...truncated fallback image...] -->
7982
</green-check>
8083

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class GreenCheck extends HTMLElement {
1414
async connectedCallback() {
1515
const shadow = this.attachShadow({ mode: 'closed' });
1616

17-
const hostname = this.getAttribute('hostname') ?? '';
17+
const hostname = this.getAttribute('hostname') ?? location.hostname;
1818
const encodedHostname = encodeURIComponent(hostname);
1919

2020
const href = GREENCHECK_BASE_URL + '?url=' + encodedHostname;
@@ -46,3 +46,4 @@ export class GreenCheck extends HTMLElement {
4646
shadow.appendChild(style);
4747
}
4848
}
49+

0 commit comments

Comments
 (0)