diff --git a/components/Schedule/index.jsx b/components/Schedule/index.jsx index 448e6a2a..c37d794f 100644 --- a/components/Schedule/index.jsx +++ b/components/Schedule/index.jsx @@ -4,6 +4,8 @@ import Day from "./Day"; import { useState, useEffect } from "react"; import { useRouter } from "next/router"; +import scheduleData from "/data/schedule.json"; + function leapYear(year) { return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; } @@ -87,8 +89,11 @@ function addDate(date, days) { } export default function Schedule(props) { - const min_date = "2023/2/14"; - const max_date = "2023/2/17"; + /* Fetch first and last day of the event from schedule data */ + const eventDates = scheduleData.map((day) => day.date).sort(); + const min_date = eventDates[0]; + const max_date = eventDates[eventDates.length - 1]; + const defaultFilter = props.filters === undefined ? "" : props.filters; //calculate default date diff --git a/layout/Home/components/Hero/Title/index.tsx b/layout/Home/components/Hero/Title/index.tsx index 747a68c2..cef62ab5 100644 --- a/layout/Home/components/Hero/Title/index.tsx +++ b/layout/Home/components/Hero/Title/index.tsx @@ -1,10 +1,21 @@ import TypeWriter from "typewriter-effect"; +import schedule from "@data/schedule.json"; +import dayjs from "dayjs"; export default function Title() { + /* Parse event dates info from schedule data */ + const dates = schedule.map((day) => day.date).sort(); + + const firstDayDate = dayjs(dates[0], "YYYY/M/D"); + const lastDayDate = dayjs(dates[dates.length - 1], "YYYY/M/D"); + + const month = firstDayDate.format("MMMM"); + const year = firstDayDate.format("YYYY"); + return (