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