@vdaluz/astro-affiliate 0.5.0 → 0.5.1
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 +8 -17
- package/package.json +1 -1
- package/src/components/AffiliateLink.astro +4 -2
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.5.1.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,7 @@ 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.
|
|
176
178
|
|
|
177
179
|
## Disclosure (`<AffiliateDisclosure>`)
|
|
178
180
|
|
|
@@ -228,17 +230,6 @@ This is a component library, not a drop-in catalog. Each consuming app owns:
|
|
|
228
230
|
[`@vdaluz/astro-blog`'s `tokens.example.css`](https://github.com/vdaluz/astro-blog) for the
|
|
229
231
|
full token set these sites already share.
|
|
230
232
|
|
|
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
233
|
## Contributing
|
|
243
234
|
|
|
244
235
|
Issues welcome. PRs by discussion - open an issue first for anything beyond a typo or docs fix.
|
package/package.json
CHANGED
|
@@ -6,11 +6,13 @@ 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 } = resolveAffiliate(config, affiliateKey, channel);
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
<a href={url} target="_blank" rel="noopener noreferrer sponsored" class={className}>
|