aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--pages/index.js34
2 files changed, 41 insertions, 2 deletions
diff --git a/README.md b/README.md
index cb9c373..8eefded 100644
--- a/README.md
+++ b/README.md
@@ -95,9 +95,16 @@ CLIENT_SECRET="get the secret from here https://anilist.co/settings/developer"
GRAPHQL_ENDPOINT="https://graphql.anilist.co"
NEXTAUTH_SECRET='run this cmd in your bash terminal (openssl rand -base64 32) with no bracket, and paste it here'
NEXTAUTH_URL="for development use http://localhost:3000/ and for production use your domain url"
+PROXY_URI="I recommend you to use this cors-anywhere as a proxy https://github.com/Rob--W/cors-anywhere follow the instruction on how to use it there."
```
-4. Start local server :
+4. Add this endpoint as Redirect Url on AniList Developer :
+
+```bash
+https://{your-website-url}/api/auth/callback/AniListProvider
+```
+
+5. Start local server :
```bash
npm run dev
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";
+ }
+}