diff --git a/src/components/AffiliateLink.tsx b/src/components/AffiliateLink.tsx new file mode 100644 index 0000000..bc5e88f --- /dev/null +++ b/src/components/AffiliateLink.tsx @@ -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 = ({ + 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 ( + + {text} + + ); +}; diff --git a/src/components/index.ts b/src/components/index.ts index c5799e8..c6bc25d 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,3 +1,4 @@ +export * from './AffiliateLink'; export * from './AmazonBook'; export * from './Book'; export * from './ColorSwatch'; diff --git a/src/mdx-components.ts b/src/mdx-components.ts index 856e431..79ab35c 100644 --- a/src/mdx-components.ts +++ b/src/mdx-components.ts @@ -1,4 +1,5 @@ import { + AffiliateLink, AmazonBook, Book, ColorSwatch, @@ -18,6 +19,7 @@ import { export const mapping = { a: TextLink, + AffiliateLink, AmazonBook, Book, ColorSwatch,