From 7fbe46603615cb22bf70b3ff4c7af0d2d1a3c64b Mon Sep 17 00:00:00 2001 From: developomp Date: Sat, 26 Mar 2022 18:48:22 +0900 Subject: [PATCH] PostList update - changed component name from `PostList` to `Home` - removed props - added basic localization --- src/App.tsx | 4 ++-- .../{PostList => Home}/ShowMoreButton.tsx | 0 src/pages/{PostList => Home}/index.tsx | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) rename src/pages/{PostList => Home}/ShowMoreButton.tsx (100%) rename src/pages/{PostList => Home}/index.tsx (83%) diff --git a/src/App.tsx b/src/App.tsx index cc1e76e..3bf64d9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,7 +8,7 @@ import Loading from "./components/Loading" import Navbar from "./components/Navbar" import Footer from "./components/Footer" -import PostList from "./pages/PostList" +import Home from "./pages/Home" import Search from "./pages/Search" import Page from "./pages/Page" import NotFound from "./pages/NotFound" @@ -80,7 +80,7 @@ export default function App() { ) : ( - } /> + } /> } /> } /> } /> diff --git a/src/pages/PostList/ShowMoreButton.tsx b/src/pages/Home/ShowMoreButton.tsx similarity index 100% rename from src/pages/PostList/ShowMoreButton.tsx rename to src/pages/Home/ShowMoreButton.tsx diff --git a/src/pages/PostList/index.tsx b/src/pages/Home/index.tsx similarity index 83% rename from src/pages/PostList/index.tsx rename to src/pages/Home/index.tsx index 6e51030..dd4259b 100644 --- a/src/pages/PostList/index.tsx +++ b/src/pages/Home/index.tsx @@ -3,7 +3,7 @@ * show posts in recent order */ -import { useEffect, useState } from "react" +import { useContext, useEffect, useState } from "react" import { Helmet } from "react-helmet-async" import styled from "styled-components" @@ -13,7 +13,9 @@ import ShowMoreButton from "./ShowMoreButton" import _map from "../../data/map.json" import theming from "../../styles/theming" -import { Map } from "../../../types/types" +import { globalContext } from "../../globalContext" + +import type { Map } from "../../../types/types" const map: Map = _map @@ -27,11 +29,8 @@ const StyledPostList = styled.div` })}; ` -interface Props { - title: string -} - -const PostList = (props: Props) => { +const PostList = () => { + const { globalState } = useContext(globalContext) const [howMany, setHowMany] = useState(5) const [postsLength, setPostsLength] = useState(0) const [postCards, setPostCards] = useState([]) @@ -67,17 +66,17 @@ const PostList = (props: Props) => { return ( <> - pomp | {props.title} + pomp | Home - + -

Recent Posts

+

{globalState.locale == "en" ? "Recent Posts" : "최근 포스트"}

{postCards} {postsLength > howMany && (