@vdaluz/astro-affiliate 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/package.json +1 -1
- package/src/components/AffiliateLink.astro +13 -3
package/README.md
CHANGED
|
@@ -6,12 +6,16 @@ Affiliate links need FTC-compliant disclosure, per-channel tracking tags for rep
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```
|
|
10
|
+
npm install @vdaluz/astro-affiliate
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Alternatively, a pinned https tarball from a tag works too, with no registry involved:
|
|
10
14
|
|
|
11
15
|
```jsonc
|
|
12
16
|
// package.json
|
|
13
17
|
"dependencies": {
|
|
14
|
-
"@vdaluz/astro-affiliate": "https://github.com/vdaluz/astro-affiliate/archive/refs/tags/v0.
|
|
18
|
+
"@vdaluz/astro-affiliate": "https://github.com/vdaluz/astro-affiliate/archive/refs/tags/v0.6.0.tar.gz"
|
|
15
19
|
}
|
|
16
20
|
```
|
|
17
21
|
|
|
@@ -19,9 +23,7 @@ Pinned https tarball from a tag (no registry needed):
|
|
|
19
23
|
> shorthand (and even an explicit `git+https://` URL) to `git+ssh://` in the lockfile.
|
|
20
24
|
> CI runners (e.g. Cloudflare Pages/Workers) have no SSH key, so `npm ci` would fail to
|
|
21
25
|
> clone it. The `/archive/refs/tags/<tag>.tar.gz` URL is anonymous https with an integrity
|
|
22
|
-
> hash in the lockfile, it just works in CI. Bump the tag in the URL to upgrade.
|
|
23
|
-
> only supported install path; there's no npm registry package (tag-tarball works for anyone,
|
|
24
|
-
> no registry auth needed).
|
|
26
|
+
> hash in the lockfile, it just works in CI. Bump the tag in the URL to upgrade.
|
|
25
27
|
|
|
26
28
|
Peer dependency: `astro` >= 6.
|
|
27
29
|
|
|
@@ -172,7 +174,16 @@ import { affiliate } from '../config/affiliate';
|
|
|
172
174
|
</AffiliateLink>
|
|
173
175
|
```
|
|
174
176
|
|
|
175
|
-
Renders `target="_blank" rel="noopener noreferrer sponsored"` by default. Pass `class` to style it.
|
|
177
|
+
Renders `target="_blank" rel="noopener noreferrer sponsored"` by default. Pass `class` to style it, or `channel` to target a per-channel tag/link (see [Per-channel tags](#per-channel-tags-reposts-syndication)) - falls back to the program's default when omitted or unconfigured for that channel.
|
|
178
|
+
|
|
179
|
+
### Click tracking
|
|
180
|
+
|
|
181
|
+
`<AffiliateLink>` renders `data-affiliate-key`, `data-affiliate-channel` (omitted when no `channel`
|
|
182
|
+
prop is passed), and `data-affiliate-program` on the anchor. This package emits no click events
|
|
183
|
+
itself - it's a data-attribute contract a consumer's own analytics wiring can read. See
|
|
184
|
+
[`@vdaluz/astro-opt-in-analytics`'s README](https://github.com/vdaluz/astro-opt-in-analytics#affiliate-click-tracking)
|
|
185
|
+
for `bindAffiliateClickTracking()`, which reads these attributes and reports an `affiliate-click`
|
|
186
|
+
event once analytics consent is granted.
|
|
176
187
|
|
|
177
188
|
## Disclosure (`<AffiliateDisclosure>`)
|
|
178
189
|
|
|
@@ -228,17 +239,6 @@ This is a component library, not a drop-in catalog. Each consuming app owns:
|
|
|
228
239
|
[`@vdaluz/astro-blog`'s `tokens.example.css`](https://github.com/vdaluz/astro-blog) for the
|
|
229
240
|
full token set these sites already share.
|
|
230
241
|
|
|
231
|
-
## Release process
|
|
232
|
-
|
|
233
|
-
Tag-pinned tarballs, no registry:
|
|
234
|
-
|
|
235
|
-
1. Test before tagging: `npm pack`, install the tarball into a scratch Astro app (or one of the
|
|
236
|
-
consumers locally), `astro check && astro build`.
|
|
237
|
-
2. Bump `version` in `package.json`, commit.
|
|
238
|
-
3. Tag `vX.Y.Z` and push the tag. **The tag must be public before any consumer CI references
|
|
239
|
-
it**, the tarball URL 404s otherwise.
|
|
240
|
-
4. Bump the tag in each consumer's `package.json` dependency URL.
|
|
241
|
-
|
|
242
242
|
## Contributing
|
|
243
243
|
|
|
244
244
|
Issues welcome. PRs by discussion - open an issue first for anything beyond a typo or docs fix.
|
package/package.json
CHANGED
|
@@ -6,13 +6,23 @@ interface Props {
|
|
|
6
6
|
config: AffiliateConfig;
|
|
7
7
|
/** Flat catalog key, e.g. 'atomicHabits'. */
|
|
8
8
|
affiliateKey: string;
|
|
9
|
+
/** Per-channel tag/link override, e.g. 'medium'. Falls back to the program's default. */
|
|
10
|
+
channel?: string;
|
|
9
11
|
class?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
const { config, affiliateKey, class: className } = Astro.props;
|
|
13
|
-
const { url } = resolveAffiliate(config, affiliateKey);
|
|
14
|
+
const { config, affiliateKey, channel, class: className } = Astro.props;
|
|
15
|
+
const { url, program } = resolveAffiliate(config, affiliateKey, channel);
|
|
14
16
|
---
|
|
15
17
|
|
|
16
|
-
<a
|
|
18
|
+
<a
|
|
19
|
+
href={url}
|
|
20
|
+
target="_blank"
|
|
21
|
+
rel="noopener noreferrer sponsored"
|
|
22
|
+
class={className}
|
|
23
|
+
data-affiliate-key={affiliateKey}
|
|
24
|
+
data-affiliate-channel={channel}
|
|
25
|
+
data-affiliate-program={program}
|
|
26
|
+
>
|
|
17
27
|
<slot />
|
|
18
28
|
</a>
|