Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable About page prefetching #1938

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontends/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
settings: {
"import/resolver": {
typescript: {
project: "*/tsconfig.json",
project: "**/tsconfig.json",
},
},
"jsx-a11y": {
Expand Down Expand Up @@ -99,14 +99,14 @@ module.exports = {
{
zones: [
{
target: "**/{components,utilities}/**",
from: "**/{pages,page-components,services}/**",
target: "**/components/**",
from: "**/{app,app-pages,page-components}/**",
message:
"Import breaks component hierarchy. See https://github.com/mitodl/mit-open/blob/main/docs/architecture/front-end-component-structure.md#module-boundary-and-importexport-rules",
},
{
target: "**/page-components/**",
from: "**/pages/**",
from: "**/{app,app-pages}/**",
message:
"Import breaks component hierarchy. See https://github.com/mitodl/mit-open/blob/main/docs/architecture/front-end-component-structure.md#module-boundary-and-importexport-rules",
},
Expand Down
14 changes: 4 additions & 10 deletions frontends/main/src/app-pages/AboutPage/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import {
theme,
styled,
} from "ol-components"
import * as urls from "@/common/urls"
import { HOME, ABOUT_NON_DEGREE_LEARNING_FRAGMENT } from "@/common/urls"
import React from "react"
import domeImage from "@/public/mit-dome-2.jpg"
import Image from "next/image"

const WHAT_IS_MIT_OPEN_FRAGMENT_IDENTIFIER = "what-is-mit-learn"
const NON_DEGREE_LEARNING_FRAGMENT_IDENTIFIER = "non-degree-learning"
const ACADEMIC_AND_PROFESSIONAL_CONTENT = "kinds-of-content"

const SITE_NAME = process.env.NEXT_PUBLIC_SITE_NAME
Expand Down Expand Up @@ -116,7 +115,7 @@ const AboutPage: React.FC = () => {
<BannerContainerInner>
<Breadcrumbs
variant="light"
ancestors={[{ href: urls.HOME, label: "Home" }]}
ancestors={[{ href: HOME, label: "Home" }]}
current="About Us"
/>
<Typography variant="h3" component="h1">
Expand Down Expand Up @@ -206,7 +205,7 @@ const AboutPage: React.FC = () => {
<Typography
variant="h4"
component="h2"
id={NON_DEGREE_LEARNING_FRAGMENT_IDENTIFIER}
id={ABOUT_NON_DEGREE_LEARNING_FRAGMENT}
>
What is non-degree learning at MIT?
</Typography>
Expand Down Expand Up @@ -257,9 +256,4 @@ const AboutPage: React.FC = () => {
)
}

export {
AboutPage,
WHAT_IS_MIT_OPEN_FRAGMENT_IDENTIFIER,
NON_DEGREE_LEARNING_FRAGMENT_IDENTIFIER,
ACADEMIC_AND_PROFESSIONAL_CONTENT as WHAT_KINDS_OF_CONTENT_FRAGMENT_IDENTIFIER,
}
export { AboutPage }
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
POPULAR_LEARNING_RESOURCES_CAROUSEL,
CERTIFICATE_COURSES_CAROUSEL,
FREE_COURSES_CAROUSEL,
} from "./carousels"
} from "../../common/carousels"
import ResourceCarousel from "@/page-components/ResourceCarousel/ResourceCarousel"
import UserListDetailsTab from "./UserListDetailsTab"
import { SettingsPage } from "./SettingsPage"
Expand Down
1 change: 1 addition & 0 deletions frontends/main/src/common/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const SETTINGS = "/dashboard/settings"
export const SEARCH = "/search"

export const ABOUT = "/about"
export const ABOUT_NON_DEGREE_LEARNING_FRAGMENT = "non-degree-learning"

export const ACCESSIBILITY = "https://accessibility.mit.edu/"

Expand Down
5 changes: 3 additions & 2 deletions frontends/main/src/page-components/HeroSearch/HeroSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
SEARCH_NEW,
SEARCH_POPULAR,
SEARCH_UPCOMING,
ABOUT_NON_DEGREE_LEARNING_FRAGMENT,
} from "@/common/urls"
import {
RiAwardLine,
Expand All @@ -26,7 +27,6 @@ import {
RiTimeLine,
RiVerifiedBadgeLine,
} from "@remixicon/react"
import { NON_DEGREE_LEARNING_FRAGMENT_IDENTIFIER } from "@/app-pages/AboutPage/AboutPage"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: This import goes against our hierearchy rules, and should have been forbidden.

Our lint rule enforcing this seems to be broken for two reasons:

  • pages needs to be renamed app-pages
  • "*/tsconfig.json" should be `"**/tsconfig.json"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout - I've updated the rules. This required moving the carousels config into common. This does import a type from @/page-components/ResourceCarousel/ResourceCarousel. Perhaps we should disallow or allow only for types.

import Image from "next/image"
import { SearchField } from "@/page-components/SearchField/SearchField"

Expand Down Expand Up @@ -221,7 +221,8 @@ const HeroSearch: React.FC<{ imageIndex: number }> = ({ imageIndex }) => {
<Typography>
Explore MIT's{" "}
<BoldLink
href={`${ABOUT}#${NON_DEGREE_LEARNING_FRAGMENT_IDENTIFIER}`}
href={`${ABOUT}#${ABOUT_NON_DEGREE_LEARNING_FRAGMENT}`}
prefetch={false}
>
Non-Degree Learning
</BoldLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { usePostHog } from "posthog-js/react"
import ResourceCarousel from "../ResourceCarousel/ResourceCarousel"
import { useIsLearningPathMember } from "api/hooks/learningPaths"
import { useIsUserListMember } from "api/hooks/userLists"
import { TopicCarouselConfig } from "@/app-pages/DashboardPage/carousels"
import { TopicCarouselConfig } from "@/common/carousels"

const RESOURCE_DRAWER_PARAMS = [RESOURCE_DRAWER_QUERY_PARAM] as const

Expand Down
1 change: 1 addition & 0 deletions frontends/ol-components/src/components/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type LinkProps = LinkStyleProps &
*/
shallow?: boolean
scroll?: boolean
prefetch?: boolean
}

const BaseLink = ({
Expand Down
Loading