mirror of
https://github.com/koodiklinikka/koodiklinikka.fi.git
synced 2026-02-08 06:50:21 +00:00
* Remove render blocking stripe JS that seems unnecessary * Use native lazy loading of images - Truly a progressive enhancement, only affects browsers that support it - Causes a warning: [Intervention] An <img> element was lazyloaded with loading=lazy, but had no dimensions specified. Specifying dimensions improves performance. See https://crbug.com/954323, which can not be easily fixed * Render content first, hydrate after that
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import React from "react";
|
|
import Document, { Html, Head, Main, NextScript } from "next/document";
|
|
import { Footer } from "../components/Footer";
|
|
import Fader from "../components/Fader";
|
|
import ReactGA from "react-ga";
|
|
|
|
function trackPageView() {
|
|
if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
|
|
return;
|
|
}
|
|
if (!window.GA_INITIALIZED) {
|
|
ReactGA.initialize("UA-58806132-1");
|
|
window.GA_INITIALIZED = true;
|
|
}
|
|
ReactGA.set({ page: window.location.pathname });
|
|
ReactGA.pageview(window.location.pathname);
|
|
}
|
|
|
|
class MyDocument extends Document {
|
|
static async getInitialProps(ctx) {
|
|
const initialProps = await Document.getInitialProps(ctx);
|
|
return { ...initialProps };
|
|
}
|
|
|
|
componentDidMount() {
|
|
trackPageView();
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<Html lang="fi">
|
|
<Head />
|
|
<body>
|
|
<div className="site">
|
|
<div className="container">
|
|
<Main />
|
|
</div>
|
|
<Footer />
|
|
</div>
|
|
<Fader />
|
|
<NextScript />
|
|
</body>
|
|
</Html>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default MyDocument;
|