From 89550dc39da5ccdb7e729c1dc2b68e5075980bd4 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Mon, 30 Jun 2025 23:52:06 -0700 Subject: adjust newsId to map non-ascii characters vercel limitation --- site/src/components/NewsFeed.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'site/src') diff --git a/site/src/components/NewsFeed.tsx b/site/src/components/NewsFeed.tsx index 881beaa..fe81148 100644 --- a/site/src/components/NewsFeed.tsx +++ b/site/src/components/NewsFeed.tsx @@ -46,7 +46,8 @@ export const NewsFeed: React.FC = ({ newsItems }) => { const initialImageIndex: Record = {}; newsItems.forEach((news) => { const contentHash = news.content.split('').reduce((hash, char) => ((hash << 5) + hash) + char.charCodeAt(0), 5381) >>> 0; - const newsId = `${news.identifier}-${news.timestamp}-${contentHash.toString(16)}-${news.headline}`; + const headlineHash = (news.headline || 'null').split('').reduce((hash, char) => ((hash << 5) + hash) + char.charCodeAt(0), 5381) >>> 0; + const newsId = `${news.identifier}-${news.timestamp}-${contentHash.toString(16)}-${headlineHash.toString(16)}`; initialImageIndex[newsId] = 0; }); setCurrentImageIndex(initialImageIndex); @@ -70,7 +71,8 @@ export const NewsFeed: React.FC = ({ newsItems }) => { {newsItems.map((news) => { const date = new Date(news.timestamp * 1000).toLocaleDateString("ja-JP", { year: "numeric", month: "2-digit", day: "2-digit" }); const contentHash = news.content.split('').reduce((hash, char) => ((hash << 5) + hash) + char.charCodeAt(0), 5381) >>> 0; - const newsId = `${news.identifier}-${news.timestamp}-${contentHash.toString(16)}-${news.headline}`; + const headlineHash = (news.headline || 'null').split('').reduce((hash, char) => ((hash << 5) + hash) + char.charCodeAt(0), 5381) >>> 0; + const newsId = `${news.identifier}-${news.timestamp}-${contentHash.toString(16)}-${headlineHash.toString(16)}`; const isEnglish = !!showEnglish[newsId]; const hasTranslation = news.en_headline || news.en_content; const displayHeadline = isEnglish && news.en_headline ? news.en_headline : news.headline; -- cgit v1.2.3