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

Next.js + Vercel! ▲ #1

Draft
wants to merge 48 commits into
base: latest
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8917b5d
Installs Next.js, removes Babel, configures Emotion (what Simorgh use…
manovotny Aug 5, 2022
b918444
Fixes lint errors.
manovotny Aug 5, 2022
245e395
Attempting to fix import aliases.
manovotny Aug 5, 2022
2d90607
Adds custom webpack moment timezone config.
manovotny Aug 5, 2022
c9ff0a9
Missed asterisks. 🤦‍♂️
manovotny Aug 5, 2022
6eba7bb
Ignoring lint on build (at least for now).
manovotny Aug 5, 2022
8775285
Starts to wire things up, largely based on setting up React Context i…
manovotny Aug 9, 2022
eb4b6fd
RENDERING!!!
manovotny Aug 10, 2022
5d255a3
Filters page data.
manovotny Aug 10, 2022
d903cb0
Fixes missing `tz` (moment timezone) data at build time.
manovotny Aug 10, 2022
cd2a576
Changes hardcoded `/news` to dynamic service.
manovotny Aug 10, 2022
b2bd31e
Swaps `getServerSideProps` for `getStaticPaths` and `getStaticProps`.
manovotny Aug 11, 2022
97f7432
Inlines front page filtering.
manovotny Aug 12, 2022
165e4e3
Adds most read section.
manovotny Aug 12, 2022
1b223e4
Adds article route / page.
manovotny Aug 13, 2022
80dfa76
Comments out unused `OptimizelyPageViewTracking` import.
manovotny Aug 13, 2022
ba2a0ed
Fixes `manifest.json` error.
manovotny Aug 13, 2022
52fef75
Removes react-helmet.
manovotny Aug 13, 2022
cc7b0b9
Fixes `pathname` undefined.
manovotny Aug 13, 2022
55bc771
Fixes WebVitals error.
manovotny Aug 14, 2022
a896926
Fixes `mostRead` prop types error.
manovotny Aug 14, 2022
5de5fb4
Updates client environment variables.
manovotny Aug 15, 2022
5bacb15
Fixes prop type error.
manovotny Aug 15, 2022
8f5bc94
Fixes article data errors due to missing filters.
manovotny Aug 15, 2022
5431714
Adds `pageType` to page routes.
manovotny Aug 15, 2022
6128a03
Updates scripts to use next/script.
manovotny Aug 15, 2022
f418e99
Fixes toggles.
manovotny Aug 16, 2022
0831d7f
Creates fake api.
manovotny Aug 16, 2022
7c851d7
Changes logger to noop.
manovotny Aug 16, 2022
cb6b004
Cleans up scripts.
manovotny Aug 16, 2022
ba19ae5
Removes helmet dependency.
manovotny Aug 16, 2022
fe51f71
Removes react-router.
manovotny Aug 16, 2022
75b33a1
Removes webpack dependencies.
manovotny Aug 16, 2022
b597af4
Removes babel dependencies.
manovotny Aug 16, 2022
9edee97
Removes express dependencies.
manovotny Aug 16, 2022
ba9fe1b
Removes isomorphic-fetch.
manovotny Aug 16, 2022
05ba343
Removes dotenv.
manovotny Aug 16, 2022
71c9f66
Removes unnecessary files.
manovotny Aug 16, 2022
c8311b7
Moves statusCode to fake API and handles error page.
manovotny Aug 17, 2022
1b0a2ea
Fixes dangling comma in template literal script code.
manovotny Aug 18, 2022
3c36090
Fixes adcampaign.
manovotny Aug 18, 2022
7d80311
Fixes Optimizely.
manovotny Aug 19, 2022
c7d1914
Removes SWR.
manovotny Aug 20, 2022
2aeb8e4
Removes webpack scripts.
manovotny Aug 23, 2022
483c5b9
Uses `withOptimizelyProvider` HOC on ArticlePage instead.
manovotny Aug 23, 2022
fe685bf
Moves environment variables to Vercel.
manovotny Aug 23, 2022
5441a38
Fixes `manifest.json` link...again.
manovotny Aug 23, 2022
bee1f79
Adds a custom `_document.js` to handle dynamic `dir` and `lang` HTML …
manovotny Aug 23, 2022
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
77 changes: 0 additions & 77 deletions .babelrc.js

This file was deleted.

32 changes: 32 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## NB only variables prefixed with NEXT_PUBLIC_SIMORGH_ are available on both the server and client
NEXT_PUBLIC_SIMORGH_BASE_URL=http://localhost:3000
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_ORIGIN=http://localhost:3000
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_PATH=/static/
NEXT_PUBLIC_SIMORGH_ATI_BASE_URL=https://logws1363.ati-host.net?
NEXT_PUBLIC_SIMORGH_CONFIG_URL=https://config.test.api.bbci.co.uk/
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_URL=https://www.test.bbc.com/ws/includes
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_AMP_URL=https://news.test.files.bbci.co.uk
NEXT_PUBLIC_SIMORGH_ICHEF_BASE_URL=https://ichef.bbci.co.uk
LOG_DIR='log'
LOG_LEVEL='debug'
LOG_TO_CONSOLE=true
NEXT_PUBLIC_SIMORGH_APP_ENV=local
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_ITEMS=100
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_MAX_AGE_SECONDS=60
NEXT_PUBLIC_SIMORGH_CONFIG_TIMEOUT_SECONDS=5
SERVER_KEEP_ALIVE_TIMEOUT=61000
SERVER_HEADERS_TIMEOUT=65000
NEXT_PUBLIC_SIMORGH_MOST_READ_CDN_URL=http://localhost:3000

## CW Custom Metrics Configuration
AWS_EMF_SERVICE_NAME=Simorgh
AWS_EMF_LOG_GROUP_NAME=SimorghServer
AWS_EMF_ENVIRONMENT=Local

## WebVitals Reporting
NEXT_PUBLIC_SIMORGH_WEBVITALS_REPORTING_ENDPOINT=https://europe-west1-bbc-otg-traf-mgr-bq-dev-4105.cloudfunctions.net/report-endpoint
NEXT_PUBLIC_SIMORGH_WEBVITALS_DEFAULT_SAMPLING_RATE=100

NEXT_PUBLIC_SIMORGH_CSP_REPORTING_ENDPOINT=https://ws.bbc-reporting-api.app/report-endpoint

NEXT_PUBLIC_SIMORGH_OPTIMIZELY_SDK_KEY=LptPKDnHyAFu9V12s5xCz
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All of these env files moved from an envConfig folder, got renamed to work with Next.js's dotenv convention, and all variables used on the client got prefixed with NEXT_PUBLIC_.

32 changes: 32 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## NB only variables prefixed with NEXT_PUBLIC_SIMORGH_ are available on both the server and client
NEXT_PUBLIC_SIMORGH_BASE_URL=https://www.bbc.com
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_ORIGIN=https://static.files.bbci.co.uk
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_PATH=/ws/simorgh-assets/public/
NEXT_PUBLIC_SIMORGH_ATI_BASE_URL=https://a1.api.bbc.co.uk/hit.xiti?
NEXT_PUBLIC_SIMORGH_CONFIG_URL=https://config.api.bbci.co.uk/
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_URL=https://www.bbc.com/ws/includes
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_AMP_URL=https://news.files.bbci.co.uk
NEXT_PUBLIC_SIMORGH_ICHEF_BASE_URL=https://ichef.bbci.co.uk
LOG_DIR='/var/log/simorgh'
LOG_LEVEL='info'
LOG_TO_CONSOLE=false
NEXT_PUBLIC_SIMORGH_APP_ENV=live
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_ITEMS=100
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_MAX_AGE_SECONDS=60
NEXT_PUBLIC_SIMORGH_CONFIG_TIMEOUT_SECONDS=1
SERVER_KEEP_ALIVE_TIMEOUT=61000
SERVER_HEADERS_TIMEOUT=65000
NEXT_PUBLIC_SIMORGH_MOST_READ_CDN_URL=https://web-cdn.api.bbci.co.uk

## CW Custom Metrics Configuration
AWS_EMF_SERVICE_NAME=Simorgh
AWS_EMF_LOG_GROUP_NAME=SimorghServer
AWS_EMF_ENVIRONMENT=EC2

## WebVitals Reporting
NEXT_PUBLIC_SIMORGH_WEBVITALS_REPORTING_ENDPOINT=https://europe-west1-bbc-otg-traf-mgr-bq-prod-4591.cloudfunctions.net/report-endpoint
NEXT_PUBLIC_SIMORGH_WEBVITALS_DEFAULT_SAMPLING_RATE=20

NEXT_PUBLIC_SIMORGH_CSP_REPORTING_ENDPOINT=https://ws.bbc-reporting-api.app/report-endpoint

NEXT_PUBLIC_SIMORGH_OPTIMIZELY_SDK_KEY=4Rje1JY7YY1FhaiHJ88Zi
32 changes: 32 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## NB only variables prefixed with NEXT_PUBLIC_SIMORGH_ are available on both the server and client
NEXT_PUBLIC_SIMORGH_BASE_URL=https://www.test.bbc.com
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_ORIGIN=https://static.test.files.bbci.co.uk
NEXT_PUBLIC_SIMORGH_PUBLIC_STATIC_ASSETS_PATH=/ws/simorgh-assets/public/
NEXT_PUBLIC_SIMORGH_ATI_BASE_URL=https://logws1363.ati-host.net?
NEXT_PUBLIC_SIMORGH_CONFIG_URL=https://config.test.api.bbci.co.uk/
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_URL=https://www.test.bbc.com/ws/includes
NEXT_PUBLIC_SIMORGH_INCLUDES_BASE_AMP_URL=https://news.test.files.bbci.co.uk
NEXT_PUBLIC_SIMORGH_ICHEF_BASE_URL=https://ichef.test.bbci.co.uk
LOG_DIR='/var/log/simorgh'
LOG_LEVEL='debug'
LOG_TO_CONSOLE=false
NEXT_PUBLIC_SIMORGH_APP_ENV=test
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_ITEMS=100
NEXT_PUBLIC_SIMORGH_CONFIG_CACHE_MAX_AGE_SECONDS=60
NEXT_PUBLIC_SIMORGH_CONFIG_TIMEOUT_SECONDS=1
SERVER_KEEP_ALIVE_TIMEOUT=61000
SERVER_HEADERS_TIMEOUT=65000
NEXT_PUBLIC_SIMORGH_MOST_READ_CDN_URL=https://web-cdn.test.api.bbci.co.uk

## CW Custom Metrics Configuration
AWS_EMF_SERVICE_NAME=Simorgh
AWS_EMF_LOG_GROUP_NAME=SimorghServer
AWS_EMF_ENVIRONMENT=EC2

## WebVitals Reporting
NEXT_PUBLIC_SIMORGH_WEBVITALS_REPORTING_ENDPOINT=https://europe-west1-bbc-otg-traf-mgr-bq-dev-4105.cloudfunctions.net/report-endpoint
NEXT_PUBLIC_SIMORGH_WEBVITALS_DEFAULT_SAMPLING_RATE=100

NEXT_PUBLIC_SIMORGH_CSP_REPORTING_ENDPOINT=https://ws.bbc-reporting-api.app/report-endpoint

NEXT_PUBLIC_SIMORGH_OPTIMIZELY_SDK_KEY=LptPKDnHyAFu9V12s5xCz
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ yarn-error.log
!.yarn/sdks
!.yarn/versions
secret.env
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo
.next
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v12.18.4
14
Copy link
Collaborator Author

@manovotny manovotny Aug 17, 2022

Choose a reason for hiding this comment

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

The move to Next.js didn't require this. Running anything below Node 14 is painful on an M1 Mac, so it was bumped up.

6 changes: 3 additions & 3 deletions .storybook/helpers/ampDecorator/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import {
AMP_SCRIPT,
AMP_NO_SCRIPT,
Expand All @@ -15,7 +15,7 @@ import {

const AmpDecorator = storyFn => (
<div>
<Helmet htmlAttributes={{ amp: '' }}>
<Head>
<link rel="canonical" href="http://foobar.com" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1" />
Expand All @@ -25,7 +25,7 @@ const AmpDecorator = storyFn => (
{AMP_GEO_JS}
{AMP_CONSENT_JS}
{AMP_ANALYTICS_JS}
</Helmet>
</Head>
{storyFn()}
</div>
);
Expand Down
32 changes: 0 additions & 32 deletions envConfig/live.env

This file was deleted.

32 changes: 0 additions & 32 deletions envConfig/local.env

This file was deleted.

32 changes: 0 additions & 32 deletions envConfig/test.env

This file was deleted.

Loading