diff --git a/.gitignore b/.gitignore index 1437c53..5fb6a59 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ yarn-error.log* # vercel .vercel +.vercelignore diff --git a/components/Item.js b/components/Item.js index 9373394..2a3fcc4 100644 --- a/components/Item.js +++ b/components/Item.js @@ -10,14 +10,14 @@ const Item = ({ item }) => { {title}
{dayjs(isoDate).fromNow()}
-
{content}
+
{content}
) } diff --git a/components/Nav.js b/components/Nav.js index f670614..d281b20 100644 --- a/components/Nav.js +++ b/components/Nav.js @@ -1,4 +1,5 @@ import Link from 'next/link' +import { useRouter } from 'next/router' import { useState } from 'react' import { feeds } from '../config/feeds' @@ -6,19 +7,77 @@ const Nav = ({ navName }) => { const [isOpen, setIsOpen] = useState(false) const toggleOpen = () => setIsOpen(!isOpen) return ( -
{ - isOpen && key === 'Escape' && setIsOpen(false) - }} - > - + {navName} +
+ + +
+ + + + ) +} + +const NavCat = ({ navName, cat, toggleOpen }) => { + const router = useRouter() + const currentCat = router.query.cat + return ( + + { strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} - d="M4 6h16M4 12h16M4 18h16" + d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" /> - - - - {navName} - - - - {isOpen && ( -
-
-
- )} -
- -
- + {navName} + + ) } diff --git a/components/Pagination.js b/components/Pagination.js index e25642d..3a76121 100644 --- a/components/Pagination.js +++ b/components/Pagination.js @@ -1,29 +1,31 @@ import ReactPaginate from 'react-paginate' const Pagination = ({ totalPage, handlePageClick }) => { - const pageClassName = - 'w-8 h-8 mx-3 flex justify-center items-center rounded-full bg-gray-100 hover:bg-gray-300' - const pageLinkClassName = 'text-lg font-medium' + const pageLinkClassName = + 'flex justify-center items-center w-8 h-8 rounded-full text-lg font-medium mx-3 bg-gray-100 hover:bg-gray-300' return ( - '} - containerClassName={'flex'} - pageClassName={`${pageClassName}`} - pageLinkClassName={pageLinkClassName} - previousClassName={pageClassName} - previousLinkClassName={pageLinkClassName} - nextClassName={pageClassName} - nextLinkClassName={pageLinkClassName} - activeClassName={'text-indigo-100 bg-indigo-600'} - activeLinkClassName={''} - disabledClassName={'opacity-40 bg-transparent'} - /> +
+
+
+ '} + containerClassName={'flex w-max mx-auto'} + pageLinkClassName={`${pageLinkClassName}`} + previousLinkClassName={pageLinkClassName} + nextLinkClassName={pageLinkClassName} + activeLinkClassName={ + 'text-white bg-blue-400 hover:text-blue-400 hover:bg-blue-200' + } + disabledClassName={'opacity-10'} + /> +
+
) } diff --git a/components/page.js b/components/page.js new file mode 100644 index 0000000..b846f1b --- /dev/null +++ b/components/page.js @@ -0,0 +1,16 @@ +import Item from './item' + +const Page = ({ pageItems }) => { + return ( +
+
+
+ {pageItems.map((item, index) => ( + + ))} +
+
+ ) +} + +export default Page diff --git a/pages/[cat].js b/pages/[cat].js index 1b54a87..dc70045 100644 --- a/pages/[cat].js +++ b/pages/[cat].js @@ -1,8 +1,8 @@ import Head from 'next/head' import { useRouter } from 'next/router' -import Item from '../components/Item' -import Nav from '../components/Nav' -import Pagination from '../components/Pagination' +import Nav from '../components/nav' +import Page from '../components/page' +import Pagination from '../components/pagination' import { getAllPaths, getFeedData } from '../lib/utils' export async function getStaticPaths() { @@ -18,7 +18,7 @@ export async function getStaticProps({ params }) { const feedData = await getFeedData(cat) return { props: { feedData }, - revalidate: 10, + revalidate: 1, } } @@ -54,18 +54,8 @@ export default function Content({ feedData }) {