diff options
| -rw-r--r-- | middleware/src/app/[gameName]/page.tsx | 4 | ||||
| -rw-r--r-- | middleware/src/app/page.tsx | 13 | ||||
| -rw-r--r-- | site/src/components/NewsFeed.tsx | 6 |
3 files changed, 19 insertions, 4 deletions
diff --git a/middleware/src/app/[gameName]/page.tsx b/middleware/src/app/[gameName]/page.tsx index 4df7efb..8bf9c0b 100644 --- a/middleware/src/app/[gameName]/page.tsx +++ b/middleware/src/app/[gameName]/page.tsx @@ -35,8 +35,8 @@ export async function generateMetadata({ news.content.split("").reduce((hash: number, char: string) => { return (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: number, char: string) => ((hash << 5) + hash) + char.charCodeAt(0), 5381) >>> 0; + const newsId = `${news.identifier}-${news.timestamp}-${contentHash.toString(16)}-${headlineHash.toString(16)}`; return newsId === postId; }); if (!matchingPost) { diff --git a/middleware/src/app/page.tsx b/middleware/src/app/page.tsx new file mode 100644 index 0000000..21fd19b --- /dev/null +++ b/middleware/src/app/page.tsx @@ -0,0 +1,13 @@ +"use client"; +import { useEffect } from 'react'; + +export default function RedirectPage() { + useEffect(() => { + const mainNewsUrl = process.env.NEXT_PUBLIC_MAIN_NEWS_URL; + if (mainNewsUrl) { + window.location.href = mainNewsUrl; + } + }, []); + + return null; +} 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<NewsFeedProps> = ({ newsItems }) => { const initialImageIndex: Record<string, number> = {}; 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<NewsFeedProps> = ({ 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; |
