mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import Head from "next/head";
|
|
import { useRouter } from "next/router";
|
|
import Script from "next/script";
|
|
import { useEffect } from "react";
|
|
import * as gtag from "../lib/gtag";
|
|
|
|
const App = ({ Component, pageProps }) => {
|
|
const router = useRouter();
|
|
useEffect(() => {
|
|
const handleRouteChange = (url) => {
|
|
gtag.pageview(url);
|
|
};
|
|
router.events.on("routeChangeComplete", handleRouteChange);
|
|
return () => {
|
|
router.events.off("routeChangeComplete", handleRouteChange);
|
|
};
|
|
}, [router.events]);
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', '${gtag.GA_TRACKING_ID}', {
|
|
page_path: window.location.pathname,
|
|
});
|
|
`,
|
|
}}
|
|
/>
|
|
</Head>
|
|
{/* Global Site Tag (gtag.js) - Google Analytics */}
|
|
<Script
|
|
strategy="afterInteractive"
|
|
src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
|
|
/>
|
|
<Component {...pageProps} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|