Skip to content

Commit

Permalink
Merge pull request #109 from samvera/104-404-redirect-to-homepage
Browse files Browse the repository at this point in the history
Add a redirect to homepage for 404s
  • Loading branch information
heathergreerklein authored Aug 21, 2023
2 parents ba36395 + b2bba22 commit 0178e38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/layout/HeaderNew.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const PopOverWrapper = ({ label, items, siteNavIndex }) => {
)} top-full rounded-3xl ring-1 ring-gray-900/5`}
>
<div className="p-4">
{items.map((item) => (
{items.map((item, idx) => (
<div
key={item.slug}
key={item.slug || item.href || idx}
className="relative flex items-center p-4 text-sm leading-6 rounded-lg group gap-x-6 hover:bg-gray-50"
>
<div className="flex-auto">
Expand Down Expand Up @@ -115,9 +115,9 @@ const DisclosureWrapper = ({ label, items }) => {
/>
</Disclosure.Button>
<Disclosure.Panel className="mt-2 space-y-2">
{[...items].map((item) => (
{[...items].map((item, idx) => (
<Disclosure.Button
key={item.slug}
key={item.slug || item.href || idx}
as="a"
href={item.href}
className="block py-2 pl-6 pr-3 text-sm leading-7 capitalize rounded-lg text-samGrey hover:bg-gray-50"
Expand Down
12 changes: 12 additions & 0 deletions pages/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useEffect } from "react";
import { useRouter } from "next/router";

export default function Custom404() {
const router = useRouter();

useEffect(() => {
router.replace("/");
});

return null;
}

0 comments on commit 0178e38

Please sign in to comment.