Remove custom _document

Looking towards a longer term transition out of next
This commit is contained in:
Manav Rathi 2024-04-05 09:59:30 +05:30
parent 9785bbcb26
commit fa7cbaea18
No known key found for this signature in database
14 changed files with 72 additions and 99 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

View file

@ -1,3 +1,4 @@
import { CustomHead } from "@/next/components/Head";
import { setupI18n } from "@/next/i18n";
import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
import { Overlay } from "@ente/shared/components/Container";
@ -15,8 +16,8 @@ import { getTheme } from "@ente/shared/themes";
import { THEME_COLOR } from "@ente/shared/themes/constants";
import { CssBaseline, useMediaQuery } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import { t } from "i18next";
import { AppProps } from "next/app";
import Head from "next/head";
import { useRouter } from "next/router";
import { createContext, useEffect, useState } from "react";
import "styles/global.css";
@ -76,16 +77,13 @@ export default function App(props: AppProps) {
const theme = getTheme(themeColor, APPS.PHOTOS);
// TODO: Localise APP_TITLES
const title = isI18nReady
? t("TITLE", { context: APPS.ACCOUNTS })
: APP_TITLES.get(APPS.ACCOUNTS);
return (
<>
<Head>
<title>{APP_TITLES.get(APPS.ACCOUNTS)}</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
</Head>
<CustomHead {...{ title }} />
<ThemeProvider theme={theme}>
<CssBaseline enableColorScheme />

View file

@ -1,3 +0,0 @@
import DocumentPage from "@ente/shared/next/pages/_document";
export default DocumentPage;

View file

@ -1,3 +1,4 @@
import { CustomHead } from "@/next/components/Head";
import { setupI18n } from "@/next/i18n";
import {
APPS,
@ -28,7 +29,6 @@ import { CssBaseline, useMediaQuery } from "@mui/material";
import { ThemeProvider } from "@mui/material/styles";
import { t } from "i18next";
import { AppProps } from "next/app";
import Head from "next/head";
import { useRouter } from "next/router";
import { createContext, useEffect, useRef, useState } from "react";
import LoadingBar from "react-top-loading-bar";
@ -129,19 +129,13 @@ export default function App(props: AppProps) {
content: t("UNKNOWN_ERROR"),
});
const title = isI18nReady
? t("TITLE", { context: APPS.AUTH })
: APP_TITLES.get(APPS.AUTH);
return (
<>
<Head>
<title>
{isI18nReady
? t("TITLE", { context: APPS.AUTH })
: APP_TITLES.get(APPS.AUTH)}
</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
</Head>
<CustomHead {...{ title }} />
<ThemeProvider theme={getTheme(themeColor, APPS.AUTH)}>
<CssBaseline enableColorScheme />

View file

@ -1,3 +0,0 @@
import DocumentPage from "@ente/shared/next/pages/_document";
export default DocumentPage;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -1,4 +1,5 @@
import { APPS } from "@ente/shared/apps/constants";
import { CustomHead } from "@/next/components/Head";
import { APPS, APP_TITLES } from "@ente/shared/apps/constants";
import { getTheme } from "@ente/shared/themes";
import { THEME_COLOR } from "@ente/shared/themes/constants";
import { CssBaseline, ThemeProvider } from "@mui/material";
@ -7,16 +8,20 @@ import "styles/global.css";
export default function App({ Component, pageProps }: AppProps) {
return (
<ThemeProvider theme={getTheme(THEME_COLOR.DARK, APPS.PHOTOS)}>
<CssBaseline enableColorScheme />
<>
<CustomHead title={APP_TITLES.get(APPS.PHOTOS)} />
<main
style={{
display: "contents",
}}
>
<Component {...pageProps} />
</main>
</ThemeProvider>
<ThemeProvider theme={getTheme(THEME_COLOR.DARK, APPS.PHOTOS)}>
<CssBaseline enableColorScheme />
<main
style={{
display: "contents",
}}
>
<Component {...pageProps} />
</main>
</ThemeProvider>
</>
);
}

View file

@ -1,27 +0,0 @@
import { Head, Html, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html
lang="en"
style={{
height: "100%",
width: "100%",
}}
>
<Head />
<body
style={{
height: "100%",
width: "100%",
margin: 0,
backgroundColor: "black",
color: "white",
}}
>
<Main />
<NextScript />
</body>
</Html>
);
}

View file

@ -1,3 +1,11 @@
body {
height: 100%;
width: 100%;
margin: 0;
background-color: black;
color: white;
}
#__next {
height: 100%;
}

View file

@ -1,3 +1,4 @@
import { CustomHead } from "@/next/components/Head";
import { setupI18n } from "@/next/i18n";
import {
APPS,
@ -48,7 +49,6 @@ import { REDIRECTS } from "constants/redirects";
import { t } from "i18next";
import isElectron from "is-electron";
import { AppProps } from "next/app";
import Head from "next/head";
import { useRouter } from "next/router";
import "photoswipe/dist/photoswipe.css";
import { createContext, useEffect, useRef, useState } from "react";
@ -378,19 +378,13 @@ export default function App(props: AppProps) {
content: t("UNKNOWN_ERROR"),
});
const title = isI18nReady
? t("TITLE", { context: APPS.PHOTOS })
: APP_TITLES.get(APPS.PHOTOS);
return (
<>
<Head>
<title>
{isI18nReady
? t("TITLE", { context: APPS.PHOTOS })
: APP_TITLES.get(APPS.PHOTOS)}
</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
</Head>
<CustomHead {...{ title }} />
<ThemeProvider theme={getTheme(themeColor, APPS.PHOTOS)}>
<CssBaseline enableColorScheme />

View file

@ -1,3 +0,0 @@
import DocumentPage from "@ente/shared/next/pages/_document";
export default DocumentPage;

View file

@ -0,0 +1,29 @@
import Head from "next/head";
import React from "react";
interface CustomHeadProps {
title: string;
}
/**
* A custom version of "next/head" that sets the title, description, favicon and
* some other boilerplate <head> tags.
*
* This assumes the existence of `public/images/favicon.png`.
*/
export const CustomHead: React.FC<CustomHeadProps> = ({ title }) => {
return (
<Head>
<title>{title}</title>
<link rel="icon" href="/images/favicon.png" type="image/png" />
<meta
name="description"
content="Ente - end-to-end encrypted cloud with open-source apps"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
</Head>
);
};

View file

@ -1,19 +0,0 @@
import { Head, Html, Main, NextScript } from "next/document";
export default function EnteDocument() {
return (
<Html lang="en">
<Head>
<meta
name="description"
content="Ente - end-to-end encrypted cloud with open-source apps"
/>
<link rel="icon" href="/images/favicon.png" type="image/png" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}