Skip to content

Commit

Permalink
✨ Replace Book Depository affiliate link with Bookshop.org
Browse files Browse the repository at this point in the history
  • Loading branch information
pouretrebelle committed Dec 18, 2024
1 parent 296c579 commit 0ca6009
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/components/BookAffiliates/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ArrowIcon from 'components/icons/ArrowIcon'
const AFFILIATE_ACTIONS = {
[AFFILIATES.GOODREADS]: 'See on Goodreads',
[AFFILIATES.AMAZON]: 'Buy on Amazon',
[AFFILIATES.BOOK_DEPOSITORY]: 'Buy on Book Depository',
[AFFILIATES.BOOKSHOP_ORG]: 'Buy on Bookshop.org',
}

const StyledLi = styled.li`
Expand Down
2 changes: 1 addition & 1 deletion src/components/YouTubeDescription/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const BookLinks: React.FC<BookLinksProps> = ({ book }) => (
)}
See on Goodreads - {book.links.short.gr}
<br />
Buy on Book Depository - {book.links.short.bd}
Buy on Bookshop.org - {book.links.short.bs}
<br />
Buy on Amazon - {book.links.short.amzn}
</>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/fragments/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const query = graphql`
long {
gr
amzn
bd
bs
}
}
title
Expand Down Expand Up @@ -80,12 +80,12 @@ export const query = graphql`
links {
short {
amzn
bd
bs
gr
}
long {
amzn
bd
bs
gr
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/types/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface Book {
long: {
gr: string
amzn: string
bd: string
bs: string
}
}
}
Expand Down Expand Up @@ -66,12 +66,12 @@ export interface BookSnapshot {
short: {
gr: string
amzn: string
bd: string
bs: string
}
long: {
gr: string
amzn: string
bd: string
bs: string
}
}
}
2 changes: 1 addition & 1 deletion src/types/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface Video {
long: {
gr: string
amzn: string
bd: string
bs: string
}
}
rating7?: number
Expand Down
6 changes: 3 additions & 3 deletions src/utils/urls/affiliates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ describe('getLink', () => {
`https://amazon.com/dp/${testIsbn10}?tag=chareads-20`
)
})
it('returns Book Depository link correctly', () => {
expect(getLink(testIsbn, AFFILIATES.BOOK_DEPOSITORY)).toEqual(
`https://bookdepository.com/search?searchTerm=${testIsbn}&a_id=char`
it('returns Bookshop.org link correctly', () => {
expect(getLink(testIsbn, AFFILIATES.BOOKSHOP_ORG)).toEqual(
`https://uk.bookshop.org/a/15033/${testIsbn}`
)
})
})
Expand Down
8 changes: 4 additions & 4 deletions src/utils/urls/affiliates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { makeIsbn10 } from 'utils/formatting/isbn'
export const AFFILIATES = {
GOODREADS: 'gr',
AMAZON: 'amzn',
BOOK_DEPOSITORY: 'bd',
}
BOOKSHOP_ORG: 'bs',
} as constå

Check failure on line 7 in src/utils/urls/affiliates.ts

View workflow job for this annotation

GitHub Actions / Deploy

Cannot find name 'constå'.

export const getLink = (isbn: string, affiliateAbbr: string): string => {
if (affiliateAbbr === AFFILIATES.GOODREADS)
Expand All @@ -13,8 +13,8 @@ export const getLink = (isbn: string, affiliateAbbr: string): string => {
if (affiliateAbbr === AFFILIATES.AMAZON)
return `https://amazon.com/dp/${makeIsbn10(String(isbn))}?tag=chareads-20`

if (affiliateAbbr === AFFILIATES.BOOK_DEPOSITORY)
return `https://bookdepository.com/search?searchTerm=${isbn}&a_id=char`
if (affiliateAbbr === AFFILIATES.BOOKSHOP_ORG)
return `https://uk.bookshop.org/a/15033/${isbn}`
}

export const getShortLink = (isbn: string, affiliateAbbr: string): string =>
Expand Down

0 comments on commit 0ca6009

Please sign in to comment.