Redirect /resources to /resources/services

This commit is contained in:
Amy 2021-06-16 22:18:05 -04:00
parent 773cba6838
commit 782ca53264
2 changed files with 21 additions and 10 deletions

View File

@ -64,7 +64,7 @@ const menu: NavLink[] = [
},
{
name: "Resources",
route: "/resources/services",
route: "/resources",
submenu: [
{
name: "Services",
@ -84,7 +84,10 @@ const menu: NavLink[] = [
function NavItem(props: NavItemProps) {
const router = useRouter();
const externalLink =
const isCurrentPage =
router.pathname === props.route ||
(props.submenu != null && router.pathname.includes(props.route));
const isExternalLink =
props.route.includes("http://") || props.route.includes("https://");
const [mobileDropdownOpen, setMobileDropdownOpen] = useState(false);
@ -97,7 +100,7 @@ function NavItem(props: NavItemProps) {
return (
<>
{externalLink ? (
{isExternalLink ? (
<a
href={props.route}
target="_blank"
@ -110,13 +113,7 @@ function NavItem(props: NavItemProps) {
<Link href={props.route}>
<a
title={props.name}
className={
router.pathname === props.route ||
((props.submenu?.length ?? 0) > 0 &&
router.pathname.split("/")[1] === props.route.split("/")[1])
? styles.currentPage
: ""
}
className={isCurrentPage ? styles.currentPage : ""}
onClick={handleClick}
>
{props.name}

14
pages/resources/index.tsx Normal file
View File

@ -0,0 +1,14 @@
import { GetStaticProps } from "next";
export const getStaticProps: GetStaticProps<{}> = async () => {
return {
redirect: {
destination: "/resources/services",
permanent: false,
},
};
};
export default function Resources() {
return null;
}