mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: add AffiliateLink component
This commit is contained in:
27
src/components/AffiliateLink.tsx
Normal file
27
src/components/AffiliateLink.tsx
Normal 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>
|
||||
);
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './AffiliateLink';
|
||||
export * from './AmazonBook';
|
||||
export * from './Book';
|
||||
export * from './ColorSwatch';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
AffiliateLink,
|
||||
AmazonBook,
|
||||
Book,
|
||||
ColorSwatch,
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
|
||||
export const mapping = {
|
||||
a: TextLink,
|
||||
AffiliateLink,
|
||||
AmazonBook,
|
||||
Book,
|
||||
ColorSwatch,
|
||||
|
||||
Reference in New Issue
Block a user