mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-01 18:00:26 +00:00
Add prettier configuration
This commit is contained in:
+72
-55
@@ -1,4 +1,10 @@
|
||||
import Document, { DocumentContext, Html, Head, Main, NextScript } from 'next/document';
|
||||
import Document, {
|
||||
DocumentContext,
|
||||
Html,
|
||||
Head,
|
||||
Main,
|
||||
NextScript,
|
||||
} from 'next/document';
|
||||
|
||||
import { ServerStyleSheet } from 'styled-components';
|
||||
|
||||
@@ -6,63 +12,74 @@ import { GOOGLE_ANALYTICS_KEY, initAnalytics } from '../utils/gtag';
|
||||
import { initStyles } from '../utils/styles';
|
||||
|
||||
class Doc extends Document {
|
||||
static async getInitialProps(ctx: DocumentContext) {
|
||||
const sheet = new ServerStyleSheet();
|
||||
const originalRenderPage = ctx.renderPage;
|
||||
static async getInitialProps(ctx: DocumentContext) {
|
||||
const sheet = new ServerStyleSheet();
|
||||
const originalRenderPage = ctx.renderPage;
|
||||
|
||||
try {
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: App => props => sheet.collectStyles(<App {...props} />)
|
||||
});
|
||||
try {
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App) => (props) =>
|
||||
sheet.collectStyles(<App {...props} />),
|
||||
});
|
||||
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
return {
|
||||
...initialProps,
|
||||
styles: (
|
||||
<>
|
||||
{initialProps.styles}
|
||||
{sheet.getStyleElement()}
|
||||
</>
|
||||
)
|
||||
};
|
||||
} finally {
|
||||
sheet.seal();
|
||||
}
|
||||
}
|
||||
const initialProps = await Document.getInitialProps(ctx);
|
||||
return {
|
||||
...initialProps,
|
||||
styles: (
|
||||
<>
|
||||
{initialProps.styles}
|
||||
{sheet.getStyleElement()}
|
||||
</>
|
||||
),
|
||||
};
|
||||
} finally {
|
||||
sheet.seal();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<link rel='shortcut icon' href='/light-favicon.png' id='light-favicon'></link>
|
||||
<link rel='shortcut icon' href='/dark-favicon.png' id='dark-favicon'></link>
|
||||
<link rel='preconnect' href='https://fonts.gstatic.com' />
|
||||
<link
|
||||
href='https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;700&display=swap'
|
||||
rel='stylesheet'
|
||||
/>
|
||||
<script src={`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_KEY}`} />
|
||||
<script
|
||||
id='analytics-init'
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: initAnalytics()
|
||||
}}
|
||||
/>
|
||||
<script
|
||||
id='styles-init'
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: initStyles()
|
||||
}}
|
||||
/>
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<link
|
||||
rel='shortcut icon'
|
||||
href='/light-favicon.png'
|
||||
id='light-favicon'
|
||||
></link>
|
||||
<link
|
||||
rel='shortcut icon'
|
||||
href='/dark-favicon.png'
|
||||
id='dark-favicon'
|
||||
></link>
|
||||
<link rel='preconnect' href='https://fonts.gstatic.com' />
|
||||
<link
|
||||
href='https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;700&display=swap'
|
||||
rel='stylesheet'
|
||||
/>
|
||||
<script
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_KEY}`}
|
||||
/>
|
||||
<script
|
||||
id='analytics-init'
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: initAnalytics(),
|
||||
}}
|
||||
/>
|
||||
<script
|
||||
id='styles-init'
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: initStyles(),
|
||||
}}
|
||||
/>
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Doc;
|
||||
|
||||
Reference in New Issue
Block a user