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

Remove CDN links #287

Merged
merged 4 commits into from
Feb 2, 2021
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
25 changes: 0 additions & 25 deletions public/static/CDN/README.md

This file was deleted.

27 changes: 27 additions & 0 deletions public/static/libs/detect-outdated-browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# `detect-outdated-browser`

> Based on https://github.com/mikemaccana/outdated-browser-rework

Copy of https://github.com/mikemaccana/outdated-browser-rework/blob/5cc5dd986d17bc168ba9699a8f4d54b42401155d/dist/outdated-browser-rework.min.js,
based on commit https://github.com/mikemaccana/outdated-browser-rework/commit/5cc5dd986d17bc168ba9699a8f4d54b42401155d

**Changes**:
- The copy has been customised to auto run the script once loaded, using the default settings.
- Also, links pointing to `http://outdatedbrowser.com/` have been replaced by `https://browser-update.org/update-browser.html` because of https://github.com/mikemaccana/outdated-browser-rework/issues/72

## Note about Next.js

There is no way to provide outdated browser support other than using external JS/CSS files, because everything in `src/components/Head.tsx` is bundled by Next.js,
and ends up bundled together, which completely fails to be loaded by outdated browsers such as IE11 which may not be able to parse the source code.

Because of this, we load an external JS file and CSS file (async if possible for perfs) so that it doesn't get bundled with the rest of the source code, but is executed on its own instead.

## Unused

This module is an experiment and has been **disabled**.

Basically, browser detection works fine, **unless running on a mobile device**,
where apps (facebook, linkedin, medium) display false-positive warnings about **embedded browsers** if they're too old,
and the user can't do anything about it (e.g: Facebook Chrome, Linkedin Chrome, etc.) because those aren't managed by the user but by the vendor instead.

The code has been kept for now, until a better solution comes to light, but it is not being used by the app.
24 changes: 14 additions & 10 deletions src/layouts/core/components/Head.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { isBrowser } from '@unly/utils';
import NextHead from 'next/head';
import React from 'react';
import {
NRN_DEFAULT_FONT,
NRN_DEFAULT_SERVICE_LABEL,
} from '@/app/constants';
import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import useCustomer from '@/modules/core/data/hooks/useCustomer';
import { Customer } from '@/modules/core/data/types/Customer';
import { SUPPORTED_LOCALES } from '@/modules/core/i18n/i18n';
import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import { isBrowser } from '@unly/utils';
import NextHead from 'next/head';
import React from 'react';

export type HeadProps = {
/**
Expand Down Expand Up @@ -66,10 +68,12 @@ export type HeadProps = {
* https://github.com/vercel/next.js#populating-head
*/
const Head: React.FunctionComponent<HeadProps> = (props): JSX.Element => {
const customer: Customer = useCustomer();

const defaultDescription = 'Flexible production-grade boilerplate with Next.js 9, Vercel and TypeScript. Includes multiple opt-in presets using Storybook, Airtable, Analytics, CSS-in-JS, Monitoring, End-to-end testing, Internationalization, CI/CD and SaaS B2B multiple single-tenants (monorepo) support';
const defaultMetaURL = 'https://github.com/UnlyEd/next-right-now';
const defaultMetaImage = '';
const defaultFavicon = '';
const defaultMetaImage = customer?.theme?.logo?.url;
const defaultFavicon = '/favicon.ico';

const {
seoTitle = NRN_DEFAULT_SERVICE_LABEL,
Expand Down Expand Up @@ -144,13 +148,13 @@ const Head: React.FunctionComponent<HeadProps> = (props): JSX.Element => {
<meta property="og:image:height" content="630" />

{/* Detect outdated browser and display a popup about how to upgrade to a more recent browser/version */}
{/* XXX See public/static/CDN/README.md */}
{/* XXX See public/static/libs/detect-outdated-browser/README.md */}
{/*
XXX DISABLED because of https://github.com/mikemaccana/outdated-browser-rework/issues/57#issuecomment-620532590
TLDR; Display false-positive warnings on embedded browsers if they're too old and the user can't do anything about it (e.g: Facebook Chrome, Linkedin Chrome, etc.)
TLDR; Display false-positive warnings on embedded browsers (on mobile devices) if they're too old and the user can't do anything about it (e.g: Facebook Chrome, Linkedin Chrome, etc.)
*/}
{/*<script async={true} src="https://storage.googleapis.com/the-funding-place/assets/libs/outdated-browser-rework/outdated-browser-rework.min.js" />*/}
{/*<link rel="stylesheet" href="https://storage.googleapis.com/the-funding-place/assets/libs/outdated-browser-rework/outdated-browser-rework.css" />*/}
{/*<script async={true} src="/assets/libs/outdated-browser-rework/outdated-browser-rework.min.js" />*/}
{/*<link rel="stylesheet" href="/assets/libs/outdated-browser-rework/outdated-browser-rework.css" />*/}

{
additionalContent && (
Expand Down
24 changes: 14 additions & 10 deletions src/layouts/demo/components/DemoHead.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { isBrowser } from '@unly/utils';
import NextHead from 'next/head';
import React from 'react';
import {
NRN_DEFAULT_FONT,
NRN_DEFAULT_SERVICE_LABEL,
} from '@/app/constants';
import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import useCustomer from '@/modules/core/data/hooks/useCustomer';
import { Customer } from '@/modules/core/data/types/Customer';
import { SUPPORTED_LOCALES } from '@/modules/core/i18n/i18n';
import { I18nLocale } from '@/modules/core/i18n/types/I18nLocale';
import { isBrowser } from '@unly/utils';
import NextHead from 'next/head';
import React from 'react';

export type HeadProps = {
seoTitle?: string;
Expand All @@ -30,10 +32,12 @@ export type HeadProps = {
* https://github.com/vercel/next.js#populating-head
*/
const DemoHead: React.FunctionComponent<HeadProps> = (props): JSX.Element => {
const customer: Customer = useCustomer();

const defaultDescription = 'Flexible production-grade boilerplate with Next.js 9, Vercel and TypeScript. Includes multiple opt-in presets using Storybook, Airtable, Analytics, CSS-in-JS, Monitoring, End-to-end testing, Internationalization, CI/CD and SaaS B2B multiple single-tenants (monorepo) support';
const defaultMetaURL = 'https://github.com/UnlyEd/next-right-now';
const defaultMetaImage = '';
const defaultFavicon = '';
const defaultMetaImage = customer?.theme?.logo?.url;
const defaultFavicon = '/favicon.ico';

const {
seoTitle = NRN_DEFAULT_SERVICE_LABEL,
Expand Down Expand Up @@ -108,13 +112,13 @@ const DemoHead: React.FunctionComponent<HeadProps> = (props): JSX.Element => {
<meta property="og:image:height" content="630" />

{/* Detect outdated browser and display a popup about how to upgrade to a more recent browser/version */}
{/* XXX See public/static/CDN/README.md */}
{/* XXX See public/static/libs/detect-outdated-browser/README.md */}
{/*
XXX DISABLED because of https://github.com/mikemaccana/outdated-browser-rework/issues/57#issuecomment-620532590
TLDR; Display false-positive warnings on embedded browsers if they're too old and the user can't do anything about it (e.g: Facebook Chrome, Linkedin Chrome, etc.)
TLDR; Display false-positive warnings on embedded browsers (on mobile devices) if they're too old and the user can't do anything about it (e.g: Facebook Chrome, Linkedin Chrome, etc.)
*/}
{/*<script async={true} src="https://storage.googleapis.com/the-funding-place/assets/libs/outdated-browser-rework/outdated-browser-rework.min.js" />*/}
{/*<link rel="stylesheet" href="https://storage.googleapis.com/the-funding-place/assets/libs/outdated-browser-rework/outdated-browser-rework.css" />*/}
{/*<script async={true} src="/assets/libs/outdated-browser-rework/outdated-browser-rework.min.js" />*/}
{/*<link rel="stylesheet" href="/assets/libs/outdated-browser-rework/outdated-browser-rework.css" />*/}

{
additionalContent && (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AppDocument extends Document<DocumentRenderProps> {
const initialProps: DocumentInitialProps = await Document.getInitialProps(ctx);
const { query } = ctx;
const hasLocaleFromUrl = !!query?.locale;
const locale: string = hasLocaleFromUrl ? query?.locale as string : DEFAULT_LOCALE; // If the locale isn't found (e.g: 404 page)
const locale: string = hasLocaleFromUrl ? query?.locale as string : DEFAULT_LOCALE; // Fallback to default locale if the locale isn't found (e.g: 404 page)
const lang: string = locale.split('-')?.[0];

return {
Expand Down