diff options
| author | Factiven <[email protected]> | 2023-05-20 11:42:08 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-05-20 11:42:08 +0700 |
| commit | 89486c64ab9d71302a78e391a8b5cf3640f592d5 (patch) | |
| tree | bf6090115c931c425cf36b6774da948e93999726 /pages | |
| parent | moved proxy to env (diff) | |
| download | moopa-89486c64ab9d71302a78e391a8b5cf3640f592d5.tar.xz moopa-89486c64ab9d71302a78e391a8b5cf3640f592d5.zip | |
Small changes
> Replaced Anilist Index to This Season on Navbar
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/index.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/pages/index.js b/pages/index.js index abe5df3..1c65970 100644 --- a/pages/index.js +++ b/pages/index.js @@ -18,6 +18,8 @@ import Genres from "../components/hero/genres"; export function Navigasi() { const { data: sessions, status } = useSession(); + const [year, setYear] = useState(new Date().getFullYear()); + const [season, setSeason] = useState(getCurrentSeason()); const router = useRouter(); @@ -46,7 +48,11 @@ export function Navigasi() { </Link> <ul className="hidden items-center gap-10 pt-2 font-outfit text-[14px] lg:flex"> <li> - <Link href="/search/anime">AniList Index</Link> + <Link + href={`/search/anime?season=${season}&seasonYear=${year}`} + > + This Season + </Link> </li> <li> <Link href="/search/manga">Manga</Link> @@ -572,3 +578,29 @@ export async function getServerSideProps(context) { }, }; } + +function getCurrentSeason() { + const now = new Date(); + const month = now.getMonth() + 1; // getMonth() returns 0-based index + + switch (month) { + case 12: + case 1: + case 2: + return "WINTER"; + case 3: + case 4: + case 5: + return "SPRING"; + case 6: + case 7: + case 8: + return "SUMMER"; + case 9: + case 10: + case 11: + return "FALL"; + default: + return "UNKNOWN SEASON"; + } +} |