feat: add AffiliateLink component

This commit is contained in:
Stefan Imhoff
2023-04-23 15:30:49 +02:00
parent 44453bdbca
commit a7b7ff8a5e
3 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import cx from 'classnames';
import type { FunctionalComponent } from 'preact';
import { TextLink } from '.';
interface Props {
asin: string;
class?: string;
text: string;
}
export const AffiliateLink: FunctionalComponent<Props> = ({
asin,
class: className,
text,
...props
}) => {
const classes = cx('affiliate', className);
const affiliateLink = `http://www.amazon.de/gp/product/${asin}?ie=UTF8&tag=stefanimhoffde-21&linkCode=as2&camp=1638&creative=6742&creativeASIN=${asin}`;
return (
<TextLink class={classes} href={affiliateLink} {...props}>
{text}
</TextLink>
);
};

View File

@@ -1,3 +1,4 @@
export * from './AffiliateLink';
export * from './AmazonBook';
export * from './Book';
export * from './ColorSwatch';

View File

@@ -1,4 +1,5 @@
import {
AffiliateLink,
AmazonBook,
Book,
ColorSwatch,
@@ -18,6 +19,7 @@ import {
export const mapping = {
a: TextLink,
AffiliateLink,
AmazonBook,
Book,
ColorSwatch,