From bc3d906e645649432b2d8a4049724c6d8645efa6 Mon Sep 17 00:00:00 2001 From: nmemmert Date: Thu, 7 May 2026 07:49:02 -0400 Subject: [PATCH] Add per-download Amazon button settings for current and archived downloads --- server/helpers.js | 4 ++++ src/AdminPage.tsx | 34 +++++++++++++++++++++++++++++++++- src/App.tsx | 13 ++++++++++++- src/content.ts | 6 ++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/server/helpers.js b/server/helpers.js index 5abf249..a843e2b 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -172,6 +172,8 @@ function sanitizeCustomLinks(value) { url: sanitizeUrl(item.url), imageUrl: sanitizeUrl(item.imageUrl), description: typeof item.description === 'string' ? item.description.trim().slice(0, 4000) : '', + amazonUrl: sanitizeUrl(item.amazonUrl), + amazonLabel: typeof item.amazonLabel === 'string' ? item.amazonLabel.trim().slice(0, 120) : '', placement, } }) @@ -199,6 +201,8 @@ function sanitizeArchivedSeriesResourceLinks(value) { label: typeof item.label === 'string' ? item.label.trim().slice(0, 120) : '', description: typeof item.description === 'string' ? item.description.trim().slice(0, 4000) : '', url: sanitizeUrl(item.url), + amazonUrl: sanitizeUrl(item.amazonUrl), + amazonLabel: typeof item.amazonLabel === 'string' ? item.amazonLabel.trim().slice(0, 120) : '', })) .filter(item => item.label && item.url) } diff --git a/src/AdminPage.tsx b/src/AdminPage.tsx index db090d5..d82338d 100644 --- a/src/AdminPage.tsx +++ b/src/AdminPage.tsx @@ -993,7 +993,7 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { ...series, resourceLinks: [ ...(series.resourceLinks ?? []), - { id: `${seriesId}-${Date.now().toString(36)}`, label: '', description: '', url: '' }, + { id: `${seriesId}-${Date.now().toString(36)}`, label: '', description: '', url: '', amazonUrl: '', amazonLabel: '' }, ], } : series), @@ -1048,6 +1048,8 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { label: source.label, description: source.description ?? '', url: source.url, + amazonUrl: source.amazonUrl ?? '', + amazonLabel: source.amazonLabel ?? '', }, ], } @@ -1075,6 +1077,8 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { label: link.label, description: link.description ?? '', url: link.url, + amazonUrl: link.amazonUrl ?? '', + amazonLabel: link.amazonLabel ?? '', })) if (toAdd.length === 0) return series @@ -1646,6 +1650,14 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { updateArchivedSeriesLink(series.id, link.id, 'url', e.target.value)} /> +
+ + updateArchivedSeriesLink(series.id, link.id, 'amazonUrl', e.target.value)} /> +
+
+ + updateArchivedSeriesLink(series.id, link.id, 'amazonLabel', e.target.value)} /> +
@@ -1724,6 +1736,10 @@ export default function AdminPage({ content, onSave, onLogout }: Props) { handleChange('studyGuideUrl', e.target.value)} /> +
+ + handleChange('studyGuideAmazonButtonLabel', e.target.value)} /> +
@@ -1756,6 +1772,14 @@ export default function AdminPage({ content, onSave, onLogout }: Props) {