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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removes react-helmet.
manovotny committed Aug 13, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 52fef75bfdc20b2afb68a2b9e3210740d34dce2a
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,
@@ -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" />
@@ -25,7 +25,7 @@ const AmpDecorator = storyFn => (
{AMP_GEO_JS}
{AMP_CONSENT_JS}
{AMP_ANALYTICS_JS}
</Helmet>
</Head>
{storyFn()}
</div>
);
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -133,7 +133,6 @@
"ramda": "0.28.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-helmet": "6.1.0",
"react-lazyload": "3.2.0",
"react-router": "5.3.1",
"react-router-config": "5.1.1",
3 changes: 1 addition & 2 deletions pages/_app.jsx
Original file line number Diff line number Diff line change
@@ -14,8 +14,7 @@ import { UserContextProvider } from '#contexts/UserContext';

const cache = createCache({ key: 'next' });

const App = props => {
const { Component, pageProps, router } = props;
const App = ({ Component, pageProps, router }) => {
const { asPath, service } = router.query;
const language = pageProps?.metadata?.language || 'en-gb';
const status = 200;
6 changes: 3 additions & 3 deletions src/app/legacy/components/MediaPlayer/Amp/index.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import { string } from 'prop-types';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import ImagePlaceholder from '#psammead/psammead-image-placeholder/src';
import Message from '../Message';

const AmpHead = () => (
<Helmet>
<Head>
<script
async
custom-element="amp-iframe"
src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"
/>
</Helmet>
</Head>
);

const AmpMediaPlayer = ({
6 changes: 3 additions & 3 deletions src/app/legacy/containers/Ad/Amp/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { oneOf } from 'prop-types';
import styled from '@emotion/styled';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import pathOr from 'ramda/src/pathOr';
import { RequestContext } from '#contexts/RequestContext';
import { ServiceContext } from '#contexts/ServiceContext';
@@ -163,11 +163,11 @@ const AmpAd = ({ slotType }) => {

return (
<>
<Helmet>
<Head>
{AMP_ADS_JS}
{AMP_ACCESS_JS}
{AMP_ACCESS_FETCH(service)}
</Helmet>
</Head>
<Advert
service={service}
script={script}
6 changes: 3 additions & 3 deletions src/app/legacy/containers/Ad/Canonical/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useContext } from 'react';
import { useLocation } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { oneOf, string } from 'prop-types';
import styled from '@emotion/styled';
import pathOr from 'ramda/src/pathOr';
@@ -71,15 +71,15 @@ const CanonicalAd = ({ slotType, className }) => {

return (
<>
<Helmet>
<Head>
{/* Add Ad scripts to document head */}
<script type="module" src={getBootstrapSrc(queryString)} async />
<script
nomodule="nomodule"
src={getBootstrapSrc(queryString, true)}
async
/>
</Helmet>
</Head>

<AdContainer
slotType={slotType}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { canonicalChartbeatPropTypes } from '#models/propTypes/chartbeatAnalytics';

const chartbeatSource = '//static.chartbeat.com/js/chartbeat.js';
@@ -17,7 +17,7 @@ const CanonicalChartbeatBeacon = ({ chartbeatConfig }) => {
}, [chartbeatConfig]);

return (
<Helmet>
<Head>
<script async type="text/javascript">
{`
(function(){
@@ -30,7 +30,7 @@ const CanonicalChartbeatBeacon = ({ chartbeatConfig }) => {
`}
</script>
<script defer type="text/javascript" src={chartbeatSource} />
</Helmet>
</Head>
);
};

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jsx-a11y/alt-text */
import React, { useContext, useEffect } from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { UserContext } from '#contexts/UserContext';

const CanonicalComscoreAnalytics = () => {
@@ -17,7 +17,7 @@ const CanonicalComscoreAnalytics = () => {
}, [personalisationEnabled]);

return (
<Helmet>
<Head>
<script
async
type="text/javascript"
@@ -26,7 +26,7 @@ const CanonicalComscoreAnalytics = () => {
<noscript>
{`<img src="https://sb.scorecardresearch.com/p?c1=2&c2=17986528&cv=2.0&cj=1" />`}
</noscript>
</Helmet>
</Head>
);
};

6 changes: 3 additions & 3 deletions src/app/legacy/containers/ConsentBanner/Banner/cookie.amp.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 { bool, string, arrayOf, element, shape } from 'prop-types';
import styled from '@emotion/styled';
import { scriptPropType } from '#psammead/gel-foundations/src/prop-types';
@@ -202,13 +202,13 @@ const AmpCookieBanner = ({

return (
<div id={id} hidden={hidden}>
<Helmet>
<Head>
<script
async
custom-element="amp-bind"
src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"
/>
</Helmet>
</Head>
<Wrapper service={service}>
<BannerPage
data-amp-bind-hidden="isManagingSettings"
6 changes: 3 additions & 3 deletions src/app/legacy/containers/ImageWithPlaceholder/index.jsx
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import styled from '@emotion/styled';
import LazyLoad from 'react-lazyload';
import ImagePlaceholder from '#psammead/psammead-image-placeholder/src';
import Image, { AmpImg } from '#psammead/psammead-image/src';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { C_GHOST } from '#psammead/psammead-styles/src/colours';
import { RequestContext } from '#contexts/RequestContext';

@@ -70,15 +70,15 @@ const ImageWithPlaceholder = ({
return (
<>
{preload && (
<Helmet>
<Head>
<link
rel="preload"
as="image"
href={src}
imagesrcset={srcset}
imagesizes={sizes}
/>
</Helmet>
</Head>
)}
<ImagePlaceholder
forwardStyle={isLoaded ? { background: 'none' } : null}
6 changes: 3 additions & 3 deletions src/app/legacy/containers/Include/amp/VjAmp.jsx
Original file line number Diff line number Diff line change
@@ -8,20 +8,20 @@ import {
import { C_EBON } from '#psammead/psammead-styles/src/colours';
import { getSansBold } from '#psammead/psammead-styles/src/font-styles';
import { GEL_PICA } from '#psammead/gel-foundations/src/typography';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { GridItemMedium } from '#components/Grid';
import { ServiceContext } from '#contexts/ServiceContext';

const KEYLINE_WIDTH = '0.125rem';

const AmpHead = () => (
<Helmet>
<Head>
<script
async
custom-element="amp-iframe"
src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"
/>
</Helmet>
</H>
);

const AmpIframe = ({ children, className, width, height, src }) => (
6 changes: 3 additions & 3 deletions src/app/legacy/containers/Include/canonical/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/no-danger */
import React from 'react';
import { string, number } from 'prop-types';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import styled from '@emotion/styled';
import { GEL_SPACING_QUIN } from '#psammead/gel-foundations/src/spacings';
import { GridItemMedium } from '#components/Grid';
@@ -38,13 +38,13 @@ const CanonicalIncludeContainer = ({ html, type, index }) => {
return (
<GridItemMedium>
{requireIncludeTypes.includes(type) && (
<Helmet>
<Head>
<script
type="text/javascript"
src="https://news.files.bbci.co.uk/include/vjassets/js/vendor/require-2.1.20b.min.js"
/>
<script>{configureAdditionalScripts}</script>
</Helmet>
</Head>
)}
<Include
suppressHydrationWarning
6 changes: 3 additions & 3 deletions src/app/legacy/containers/LinkedData/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { string, shape, arrayOf, bool, object } from 'prop-types';
import { ServiceContext } from '#contexts/ServiceContext';
import { RequestContext } from '#contexts/RequestContext';
@@ -105,14 +105,14 @@ const LinkedData = ({
};

return (
<Helmet>
<Head>
<script type="application/ld+json">
{serialiseForScript({
'@context': 'http://schema.org',
'@graph': [{ ...linkedData }, ...entities],
})}
</script>
</Helmet>
</Head>
);
};

6 changes: 3 additions & 3 deletions src/app/legacy/containers/Manifest/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { ServiceContext } from '#contexts/ServiceContext';

const ManifestContainer = () => {
@@ -10,9 +10,9 @@ const ManifestContainer = () => {
}

return (
<Helmet>
<Head>
<link rel="manifest" href={`/public/${service}${manifestPath}`} />
</Helmet>
</Head>
);
};

6 changes: 3 additions & 3 deletions src/app/legacy/containers/MediaPlayer/Metadata.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 pathOr from 'ramda/src/pathOr';
import { shape, string } from 'prop-types';
import { mediaPlayerMetadata } from './helpers/metadata';
@@ -14,11 +14,11 @@ const Metadata = ({ aresMediaBlock, embedSource }) => {
const metadata = mediaPlayerMetadata(aresMediaBlocks, embedSource);

return (
<Helmet>
<Head>
{metadata && (
<script type="application/ld+json">{JSON.stringify(metadata)}</script>
)}
</Helmet>
</Head>
);
};

7 changes: 0 additions & 7 deletions src/app/legacy/containers/Metadata/index.jsx
Original file line number Diff line number Diff line change
@@ -99,20 +99,13 @@ const MetadataContainer = ({
},
];

const htmlAttributes = {
dir,
lang,
...(isAmp && { amp: '' }), // empty value as this makes Helmet render 'amp' as per https://www.ampproject.org/docs/fundamentals/spec#ampd
};

const pageTitle = `${title} - ${brandName}`;
const socialTitle = `${socialHeadline || title} - ${brandName}`;

const metaImage = image || defaultImage;
const metaImageAltText = imageAltText || defaultImageAltText;
const linkToAmpPage = hasAmpPage && !isAmp;

// MNTODO: Check head elements render correctly.
return (
<Head>
<meta name="theme-color" content={themeColor} />
27 changes: 14 additions & 13 deletions src/app/legacy/containers/MostRead/Amp/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Helmet } from 'react-helmet';
import Head from 'next/head';
import { string, oneOf, elementType } from 'prop-types';
import styled from '@emotion/styled';
import {
@@ -73,17 +73,18 @@ const AmpMostRead = ({ endpoint, size, wrapper: Wrapper }) => {
return (
<amp-script id="dataFunctions" script="local-script">
<Wrapper>
<Helmet
script={[
{
id: 'local-script',
type: 'text/plain',
target: 'amp-script',
innerHTML: onlyinnerscript,
},
]}
/>
<Helmet>
<Head>
<script
id="local-script"
type="text/plain"
target="amp-script"
custom-element="amp-iframe"
src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"
>
`${onlyinnerscript}`
</script>
</Head>
<Head>
{/* Import required amp scripts for most read */}
{AMP_LIST_JS}
{AMP_MUSTACHE_JS}
@@ -97,7 +98,7 @@ const AmpMostRead = ({ endpoint, size, wrapper: Wrapper }) => {
'base64',
)}
/>
</Helmet>
</Head>

<amp-list
src="amp-script:dataFunctions.getRemoteData"
Loading