Skip to content

Commit

Permalink
Develop news page
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian0701 committed Feb 20, 2023
1 parent c11680c commit de1120e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 10 deletions.
Binary file added public/img/newsPage_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/common/news_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import myStyles from "@/styles/about.module.css";
import NewsItems from "./news_items";
import { getAllNews } from "@/interfaces/news_detail";

function NewsList(max = 4) {
function NewsList(props: { max: number }) {
const newsData = getAllNews();
if (max > 6) {
if (props.max > 6) {
newsData.splice(4);
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/news/newsBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function NewsBody(props: {
<p>{props.contents}</p>
</div>
</div>
<button>
<Link href="/news">{t("news.goBack")}</Link>
</button>
<Link href="/news" className={myStyles.goBackBtn}>
<button>{t("news.goBack")}</button>
</Link>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/news/[newsId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function NewsDetailPage() {
const news = getNewsById(newsId as string);

return (
<div className={myStyles.news_main_container}>
<div className={myStyles.news_detail_container}>
<NewsBody
title={news.title}
date={news.date}
Expand Down
24 changes: 22 additions & 2 deletions src/pages/news/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
import { useTranslation } from "next-i18next";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import NewsList from "@/components/common/news_list";
import myStyles from "@/styles/news.module.css";

function AllNewsPage() {
const { t } = useTranslation("common");

return (
<div style={{ padding: "20rem" }}>
<h1>This is All news page</h1>
<div className={myStyles.news_main_container}>
<div className={myStyles.news_main_banner}>
<h1>{t("news.title")}</h1>
</div>

<NewsList max={Infinity} />
</div>
);
}
export default AllNewsPage;

export async function getStaticProps({ locale }: any) {
return {
props: {
...(await serverSideTranslations(locale, ["common"])),
// Will be passed to the page component as props
},
};
}
31 changes: 29 additions & 2 deletions src/styles/news.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
/* all news */
.news_main_container {
padding: 5rem 0 6rem 0;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #f8fafa;
color: #3a3b4d;
}

.news_main_banner {
width: 100%;
height: 450px;
background: url("/img/newsPage_banner.png") no-repeat top center / cover;
display: flex;
align-items: center;
justify-content: center;
}

.news_main_banner h1 {
font: normal normal 36px/58px Noto Sans TC;
}

/* news detail */
.news_detail_container {
padding: 10rem 6rem 6rem 6rem;
min-height: 100vh;
display: flex;
Expand Down Expand Up @@ -50,7 +76,7 @@
text-align: left;
}

.news_body_container button {
.goBackBtn button {
padding: 10px;
width: 120px;
background-color: #31d3f5;
Expand All @@ -59,10 +85,11 @@
color: #3a3b4d;
font: normal normal 18px/26px Noto Sans TC;
letter-spacing: 0.09px;
cursor: pointer;
transition: all 0.1s ease-in;
}

.news_body_container button:hover {
.goBackBtn button:hover {
background-color: transparent;
color: #31d3f5;
}
Expand Down

0 comments on commit de1120e

Please sign in to comment.