Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
cd5b970
Next.js scaffold
jonkafton Aug 14, 2024
061c6e2
Supply env vars on process.env.NEXT_PUBLIC_
jonkafton Aug 14, 2024
7d52948
Replace react-router hook with next/navigation
jonkafton Aug 14, 2024
cce398f
MUI theme provider for Next.js
jonkafton Aug 14, 2024
9d0b321
Styled elements
jonkafton Aug 14, 2024
2aeb458
Restructuring to bring pages and components into ssr project
jonkafton Aug 15, 2024
0f4e311
Images and link fixes
jonkafton Aug 15, 2024
e55fd33
Set up prerendering with React Query and fetch Featured Courses carou…
jonkafton Aug 15, 2024
b607247
Head meta tags
jonkafton Aug 16, 2024
73d87fa
Main entrypoint. Include in yarn workspaces. API URL for local
jonkafton Aug 19, 2024
c35ec3e
Add remaining homepage sections
jonkafton Aug 20, 2024
1c5d744
Move into frontends
jonkafton Aug 20, 2024
0959297
Lint fixes
jonkafton Aug 20, 2024
27b5e57
Routed drawer and updates for homepage resource drawer search triggers
jonkafton Aug 20, 2024
a5457da
Move pages (conflict with Next.js Pages Router)
jonkafton Aug 20, 2024
ce8a5b1
Webpack configs for babel loader (import type) and ignore test files …
jonkafton Aug 20, 2024
9a09083
Typescript config, move common/urls
jonkafton Aug 20, 2024
ce8afec
Updates towards successful build
jonkafton Aug 22, 2024
043537b
Suspense boudary for header useSearchParam
jonkafton Aug 22, 2024
5cd5c35
Provide origin on environment (cannot reference window)
jonkafton Aug 22, 2024
33f5621
Update drawer hooks for next/navigation
jonkafton Aug 22, 2024
fc31579
Unit listing page and dependencies
jonkafton Aug 22, 2024
3bfb641
Image fixes. ol-component compatibility updates
jonkafton Aug 23, 2024
f59fd7d
Logo image fixes and footer image
jonkafton Aug 23, 2024
f7dec20
Search page
jonkafton Aug 23, 2024
7dab50a
Remove temp course-serach-utils
jonkafton Aug 23, 2024
98d5e74
Remove temp course-serach-utils
jonkafton Aug 23, 2024
d9e8023
Channel Page. Rewrite for image paths
jonkafton Aug 23, 2024
33e2772
Merge branch 'jk/evaluate-nextjs' of https://github.com/mitodl/mit-op…
jonkafton Aug 23, 2024
edadc7c
Move @mui/material-nextjs into ol-components
jonkafton Aug 23, 2024
a99bf81
Department listing page
jonkafton Aug 23, 2024
3067ac2
Topic listing page
jonkafton Aug 23, 2024
e0b314d
Terms page
jonkafton Aug 23, 2024
8b5e8c2
Privacy page
jonkafton Aug 23, 2024
9922294
Image paths
jonkafton Aug 26, 2024
97c82db
Lockfile
jonkafton Aug 26, 2024
dcd7237
Merge branch 'main' into jk/evaluate-nextjs
jonkafton Aug 26, 2024
3bef5c7
Migrates the dashboard pages
jonkafton Aug 26, 2024
369b119
Migrate learning path listing page
jonkafton Aug 26, 2024
45726ab
Migrate learning path details page
jonkafton Aug 27, 2024
471f800
Prettier fixes
jonkafton Aug 27, 2024
31bffb3
Migrate test utils. Fixes for passing typechecks on test files (exclu…
jonkafton Aug 27, 2024
b11d0ab
Migrate the onboarding page
jonkafton Aug 27, 2024
c0e13c1
Migrate program letter page
jonkafton Aug 27, 2024
a5612fd
Migrate error page
jonkafton Aug 27, 2024
ea20ce5
Resolves issue with Server Components treated as Client Components (t…
jonkafton Aug 28, 2024
76b6478
Metadata utility
jonkafton Aug 28, 2024
52a6dc9
Fetch learning resource for metadata when drawer is open
jonkafton Aug 28, 2024
ecae36f
Async and sync metadata utilities
jonkafton Aug 28, 2024
2b5d3b7
Merge branch 'main' into jk/evaluate-nextjs
jonkafton Aug 29, 2024
7c02133
.env example file
jonkafton Aug 29, 2024
d386300
Merge branch 'main' into nextjs
jonkafton Aug 29, 2024
fcd31b0
Merge branch 'main' into nextjs
jonkafton Aug 30, 2024
1d683df
Merge branch 'main' into nextjs
jonkafton Aug 30, 2024
7f4d689
Preserve hero image aspect
jonkafton Aug 30, 2024
03e8cc9
Put back SliderInput
jonkafton Aug 30, 2024
6b70bde
Merge branch 'main' into jk/5244-nextjs-initial-migration
jonkafton Sep 3, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@ storybook-static/
/e2e_testing/playwright/.cache/
!/e2e_testing/.env

/**/.yarn/cache
e2e_testing/.yarn/cache
.swc
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
openapi/specs/*
.yarn/
.next/
4 changes: 3 additions & 1 deletion frontends/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"./hooks/*": "./src/hooks/*/index.ts",
"./constants": "./src/common/constants.ts",
"./test-utils/factories": "./src/test-utils/factories/index.ts",
"./test-utils": "./src/test-utils/index.ts"
"./test-utils": "./src/test-utils/index.ts",
"./ssr": "./src/ssr.ts"
},
"peerDependencies": {
"react": "18.3.1"
Expand All @@ -18,6 +19,7 @@
"@faker-js/faker": "^8.0.0",
"@testing-library/react": "16.0.1",
"enforce-unique": "^1.3.0",
"jest": "^29.7.0",
"jest-when": "^3.6.0",
"lodash": "^4.17.21",
"ol-test-utilities": "0.0.0"
Expand Down
5 changes: 3 additions & 2 deletions frontends/api/src/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import axios from "axios"
* Our axios instance with default baseURL, headers, etc.
*/
const instance = axios.create({
xsrfCookieName: APP_SETTINGS.CSRF_COOKIE_NAME,
xsrfCookieName: process.env.NEXT_PUBLIC_CSRF_COOKIE_NAME,
xsrfHeaderName: "X-CSRFToken",
withXSRFToken: true,
withCredentials: APP_SETTINGS.MITOL_AXIOS_WITH_CREDENTIALS,
withCredentials:
process.env.NEXT_PUBLIC_MITOL_AXIOS_WITH_CREDENTIALS === "true",
})

export default instance
4 changes: 3 additions & 1 deletion frontends/api/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {

import axiosInstance from "./axios"

const { MITOL_API_BASE_URL } = APP_SETTINGS
const MITOL_API_BASE_URL = (<any>process).browser
? process.env.NEXT_PUBLIC_MITOL_API_BASE_URL
: process.env.MITOL_API_BASE_URL
Comment on lines +27 to +29
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this can just be const MITOL_API_BASE_URL = NEXT_PUBLIC_MITOL_API_BASE_URL.


const BASE_PATH = MITOL_API_BASE_URL?.replace(/\/+$/, "") ?? ""

Expand Down
10 changes: 10 additions & 0 deletions frontends/api/src/ssr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {
isServer,
Hydrate,
QueryClient,
QueryClientProvider,
dehydrate,
useQueries,
} from "@tanstack/react-query"

export type { UseQueryResult, UseQueryOptions } from "@tanstack/react-query"
6 changes: 3 additions & 3 deletions frontends/api/src/test-utils/factories/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const departmentChannel: PartialFactory<DepartmentChannel> = (
{ channel_type: ChannelTypeEnum.Department },
{
configuration: {
banner_background: "/static/images/unit_banners/mitpe.jpg",
banner_background: "/images/unit_banners/mitpe.jpg",
heading: "test",
logo: "/static/test.svg",
name: "test",
Expand All @@ -73,7 +73,7 @@ const topicChannel: PartialFactory<TopicChannel> = (overrides = {}) => {
{ channel_type: ChannelTypeEnum.Topic },
{
configuration: {
banner_background: "/static/images/unit_banners/mitpe.jpg",
banner_background: "/images/unit_banners/mitpe.jpg",
heading: "test",
logo: "/static/test.svg",
name: "test",
Expand All @@ -96,7 +96,7 @@ const unitChannel: PartialFactory<UnitChannel> = (overrides = {}) => {
{ channel_type: ChannelTypeEnum.Unit },
{
configuration: {
banner_background: "/static/images/unit_banners/mitpe.jpg",
banner_background: "/images/unit_banners/mitpe.jpg",
heading: "test",
logo: "/static/test.svg",
name: "test",
Expand Down
1 change: 1 addition & 0 deletions frontends/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const projectsConfig: Config.InitialOptions = {
collectCoverage: true,
coverageDirectory: "coverage",
projects: ["<rootDir>/*/jest.config.ts"],
modulePathIgnorePatterns: ['<rootDir>/mit-learn/'],
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
Expand Down
10 changes: 10 additions & 0 deletions frontends/main/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
NEXT_PUBLIC_ORIGIN=http://open.odl.local:8062
NEXT_PUBLIC_MITOL_API_BASE_URL=http://open.odl.local:8063
MITOL_API_BASE_URL=http://open.odl.local:8063

NEXT_PUBLIC_PUBLIC_URL=/
NEXT_PUBLIC_SITE_NAME=MIT Learn
NEXT_PUBLIC_MITOL_SUPPORT_EMAIL=mitlearn-support@mit.edu
NEXT_PUBLIC_EMBEDLY_KEY=
NEXT_PUBLIC_MITOL_AXIOS_WITH_CREDENTIALS=true
NEXT_PUBLIC_CSRF_COOKIE_NAME=csrftoken-local # Must match CSRF_COOKIE_NAME on the backend's environment
36 changes: 36 additions & 0 deletions frontends/main/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
36 changes: 36 additions & 0 deletions frontends/main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
27 changes: 27 additions & 0 deletions frontends/main/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import path, { resolve } from "path"
import type { Config } from "@jest/types"
import baseConfig from "../jest.jsdom.config"

const config: Config.InitialOptions = {
...baseConfig,
setupFilesAfterEnv: [
...baseConfig.setupFilesAfterEnv,
resolve(__dirname, "./test-utils/setupJest.ts"),
],
moduleNameMapper: {
"^@/(.*)$": resolve(__dirname, "src/$1"),
"^@/test-utils$": resolve(__dirname, "test-utils"),
...baseConfig.moduleNameMapper,
},
transformIgnorePatterns: ["/node_modules/(?!(" + "yaml", ")/)"],
globals: {
APP_SETTINGS: {
EMBEDLY_KEY: "embedly_key",
MITOL_API_BASE_URL: "https://api.test.learn.mit.edu",
PUBLIC_URL: "",
SITE_NAME: "MIT Learn",
},
},
}

export default config
116 changes: 116 additions & 0 deletions frontends/main/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// @ts-check

/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (
config,
{ buildId, dev, isServer, defaultLoaders, nextRuntime, webpack },
) => {
config.plugins.push(
new webpack.IgnorePlugin({
resourceRegExp: /\.test\.tsx$/,
}),
new webpack.IgnorePlugin({
resourceRegExp: /mockAxios\.ts/,
}),
)

// Do not do this. Added to fix "import type", but causes a strage issue where
// the root page and layout think they're Client Components and "use client"
// directives not properly respected.
// https://nextjs.org/docs/app/api-reference/next-config-js/webpack
//
// config.module.rules.push({
// test: /\.tsx?$/,
// use: [defaultLoaders.babel],
// })

return config
},

async rewrites() {
return [
/* Images moved from /static, though image paths are sometimes
* returned on the API, e.g. /api/v0/channels/type/unit/ocw/
* TODO update API paths and remove the rewrite.
*/
{
source: "/static/images/:path*",
destination: "/images/:path*",
},
]
},

images: {
remotePatterns: [
{
protocol: "https",
hostname: "*.mit.edu",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "i.embed.ly",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "ol-xpro-app-production.s3.amazonaws.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "*.cloudfront.net",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "*.edx-cdn.org",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "i.ytimg.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "i1.sndcdn.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "*.medium.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "image.simplecastcdn.com",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "megaphone.imgix.net",
port: "",
pathname: "**",
},
{
protocol: "https",
hostname: "artwork.captivate.fm",
port: "",
pathname: "**",
},
],
},
}

module.exports = nextConfig
Loading