fix the PR gated

This commit is contained in:
Yifei Hu 2024-07-10 11:20:06 +08:00
parent effd1d38d0
commit ca4dfec84b
4 changed files with 31 additions and 7 deletions

View file

@ -1,7 +1,6 @@
import { fetchNewsData } from "../../../lib/fetchNewsData";
import NewsDetail from "../../../components/NewsDetail";
export default async function NewsPage({ params }: { params: { id: string } }) {
const newsData = await fetchNewsData(params.id);
@ -10,4 +9,4 @@ export default async function NewsPage({ params }: { params: { id: string } }) {
}
return <NewsDetail news={newsData} />;
}
}

View file

@ -9,4 +9,4 @@ const Layout = ({ children }: { children: React.ReactNode }) => {
return <div>{children}</div>;
};
export default Layout;
export default Layout;

View file

@ -1,13 +1,38 @@
import React from "react";
import ContextItem from "./ContextItem";
interface ContextItemType {
name: string;
url: string;
description: string;
provider: {
name: string;
image?: {
thumbnail: {
contentUrl: string;
};
};
}[];
datePublished: string;
image?: {
contentUrl: string;
thumbnail: {
contentUrl: string;
width: number;
height: number;
};
};
article?: string;
score?: number;
}
interface NewsDetailProps {
news: {
title: string;
sections: {
title: string;
content: string;
context: any[];
context: ContextItemType[];
}[];
};
}
@ -32,4 +57,4 @@ const NewsDetail: React.FC<NewsDetailProps> = ({ news }) => {
);
};
export default NewsDetail;
export default NewsDetail;

View file

@ -52,7 +52,7 @@ const NewsPage = () => {
<div className="flex flex-row items-center justify-center min-h-screen">
<p className="text-black/70 dark:text-white/70 text-sm">Loading news...</p>
</div>
) : error ? (
) : (error ? (
<div className="flex flex-col items-center justify-center min-h-screen">
<p className="text-red-500 text-sm mb-2">Failed to load news.</p>
<p className="text-red-500 text-xs">{error}</p>
@ -77,7 +77,7 @@ const NewsPage = () => {
))
)}
</div>
)}
))}
</div>
);
};