diff --git a/.htaccess b/.htaccess index 76850f0..be8cab2 100644 --- a/.htaccess +++ b/.htaccess @@ -1,13 +1,14 @@ # Enable rewrite engine RewriteEngine On -# Check if the .html version of the requested resource exists -RewriteCond %{REQUEST_FILENAME}.html -f -# Rewrite to .html version if existing (for requests without an extension) -RewriteRule ^([^\.]+)$ $1.html [NC,L] +# Redirect requests to .html when the .html file exists +# This works even if a directory with the same name exists +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{DOCUMENT_ROOT}/$1.html -f +RewriteRule ^(.*?)/?$ $1.html [NC,L] # Custom error document -ErrorDocument 404 /404.html +ErrorDocument 404 /~cis1951/404.html # Internally rewrite requests to 404.html, while maintaining the 404 status RewriteCond %{ENV:REDIRECT_STATUS} ^$ diff --git a/app/assignments/page.tsx b/app/assignments/page.tsx index e002fb3..13f801d 100644 --- a/app/assignments/page.tsx +++ b/app/assignments/page.tsx @@ -1,8 +1,7 @@ import { allHomework, allAssessments } from 'contentlayer/generated' import { Card } from '@/components/Card' import Link from 'next/link' -import { FormattedDate, defaultTimezone } from '@/components/FormattedDate' -import { toDate } from 'date-fns-tz' +import { FormattedDate } from '@/components/FormattedDate' type Assignment = { title: string @@ -17,22 +16,18 @@ type Assignment = { sortDate: Date } -export function parseDate(str: string) { - return toDate(str, { timeZone: defaultTimezone }) -} - export const formattedHomework: Assignment[] = allHomework.map(hw => { - const due = parseDate(hw.dueDate) + const due = new Date(hw.dueDate) return { title: hw.title, href: `/assignments/hw/${hw.slug}`, isReleased: hw.isReleased, - releaseDate: hw.releaseDate && parseDate(hw.releaseDate), + releaseDate: hw.releaseDate && new Date(hw.releaseDate), dates: [ ...(hw.auxiliaryDates ?? []).map(aux => ({ name: aux.name, - date: parseDate(aux.date), + date: new Date(aux.date), specifyTime: true, })), { @@ -41,18 +36,18 @@ export const formattedHomework: Assignment[] = allHomework.map(hw => { specifyTime: true, } ], - sortDate: parseDate(hw.dueDate), + sortDate: new Date(hw.dueDate), } }) export const formattedAssessments = allAssessments.map(a => { - const date = parseDate(a.assessmentDate) + const date = new Date(a.assessmentDate) return { title: a.title, href: `/assignments/assessment/${a.slug}`, isReleased: a.isReleased, - releaseDate: a.releaseDate && parseDate(a.releaseDate), + releaseDate: a.releaseDate && new Date(a.releaseDate), dates: [ { name: "Scheduled", diff --git a/app/menu.tsx b/app/menu.tsx index 04e0a03..0e8bf49 100644 --- a/app/menu.tsx +++ b/app/menu.tsx @@ -78,9 +78,10 @@ export type MenuItemActivatorProps = { export function MenuItemActivator({ item }: MenuItemActivatorProps) { const context = useMenuContext() + const pathname = usePathname() useEffect(() => { context.setActiveItem(item) - }, []) + }, [pathname]) return null } @@ -100,14 +101,7 @@ function MenuItem({ id, title, icon, href }: MenuItemProps) { let containerClassName = "flex gap-3 transition-[margin-left] justify-center text-center md:text-left" if (!isActive) containerClassName += " md:group-hover:ml-1" - return { - if (href === "/") { - // HACK: For some reason navigating to / forces a full refresh - // So we just intercept it and do it ourselves instead - router.push("/") - e.preventDefault() - } - }}> + return
{icon}
{title}
diff --git a/components/UpcomingAssignments.tsx b/components/UpcomingAssignments.tsx index eda26c1..be07a74 100644 --- a/components/UpcomingAssignments.tsx +++ b/components/UpcomingAssignments.tsx @@ -1,6 +1,6 @@ import { formattedAssessments, formattedHomework, AssignmentTable } from "@/app/assignments/page" -const threshold = 5 * 7 * 24 * 60 * 60 * 1000 // 3 weeks +const threshold = 3 * 7 * 24 * 60 * 60 * 1000 // 3 weeks const thresholdText = "3 weeks" const upcoming = [...formattedHomework, ...formattedAssessments].filter(({ sortDate }) => { diff --git a/content/homework/hw0.mdx b/content/homework/hw0.mdx index 5f8ed68..f60ca9b 100644 --- a/content/homework/hw0.mdx +++ b/content/homework/hw0.mdx @@ -1,7 +1,7 @@ --- title: HW0 - Xcode Setup isReleased: true -dueDate: 2024-01-22T23:59:00 +dueDate: 2024-01-22T23:59:00-05:00 --- Just send us a screenshot of Xcode working \ No newline at end of file diff --git a/content/homework/hw1.mdx b/content/homework/hw1.mdx index 31159f6..758c718 100644 --- a/content/homework/hw1.mdx +++ b/content/homework/hw1.mdx @@ -1,6 +1,6 @@ --- title: HW1 - Basic Swift isReleased: false -dueDate: 2024-01-23T23:59:00 -releaseDate: 2024-01-24T23:59:00 +dueDate: 2024-01-23T23:59:00-05:00 +releaseDate: 2024-01-24T23:59:00-05:00 --- \ No newline at end of file diff --git a/next.config.js b/next.config.js index 01f0214..7ed2b2b 100644 --- a/next.config.js +++ b/next.config.js @@ -5,6 +5,7 @@ const nextConfig = { basePath: "/~cis1951", output: "export", pageExtensions: ["js", "jsx", "ts", "tsx", "mdx"], + trailingSlash: true, } module.exports = withContentlayer(nextConfig) \ No newline at end of file