Skip to content

Commit

Permalink
Merge pull request #892 from CodeForAfrica/feat/engineeringblog_analy…
Browse files Browse the repository at this point in the history
…tics

@/engineeringblog GA analytics
  • Loading branch information
kilemensi authored Sep 18, 2024
2 parents a47f3e8 + 4429576 commit a1668dd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
9 changes: 5 additions & 4 deletions apps/engineeringblog/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CssBaseline, ThemeProvider } from "@mui/material";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v13-appRouter";
import { GoogleAnalytics } from "@next/third-parties/google";
import type { Metadata } from "next";

import logoLight from "@/engineeringblog/assets/images/logo-light.png";
import Footer from "@/engineeringblog/components/Footer";
import NavBar from "@/engineeringblog/components/NavBar";
import theme from "@/engineeringblog/theme";

import { getSettings } from "@/engineeringblog/lib/data";
import logoLight from "@/engineeringblog/assets/images/logo-light.png";
import theme from "@/engineeringblog/theme";

export const metadata: Metadata = {
title: "Technology | Code for Africa",
Expand All @@ -20,7 +20,7 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const { connect, primaryNavigation, secondaryNavigation } =
const { analytics, connect, primaryNavigation, secondaryNavigation } =
await getSettings();
// TODO: blurWidth/blurHeight https://github.com/vercel/next.js/issues/56511
const { blurWidth, blurHeight, ...logoProps } = logoLight;
Expand All @@ -46,6 +46,7 @@ export default async function RootLayout({
</ThemeProvider>
</AppRouterCacheProvider>
</body>
<GoogleAnalytics gaId={analytics?.analyticsId} />
</html>
);
}
2 changes: 2 additions & 0 deletions apps/engineeringblog/content/site/settings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ connect:
url: https://www.instagram.com/code4africa__/
- platform: Github
url: https://github.com/CodeForAfrica
analytics:
analyticsId: "G-TN1WGZVHLE"
---
6 changes: 6 additions & 0 deletions apps/engineeringblog/lib/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,23 @@ interface SecondaryNavigationProps extends NavigationProps {
copyright: string;
}

export type AnalyticsProps = {
analyticsId: string;
};

type SettingsProps = {
title: string;
primaryNavigation: PrimaryNavigationProps;
secondaryNavigation: SecondaryNavigationProps;
connect: ConnectProps;
analytics: AnalyticsProps;
};

async function readSettingsFile(filePath: string): Promise<SettingsProps> {
const { data } = await readMdFile(filePath);

return {
analytics: data.analytics,
connect: data.connect,
primaryNavigation: data.primaryNavigation,
secondaryNavigation: data.secondaryNavigation,
Expand Down
1 change: 1 addition & 0 deletions apps/engineeringblog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@mui/material-nextjs": "catalog:",
"@mui/utils": "catalog:",
"@next/mdx": "catalog:",
"@next/third-parties": "catalog:",
"date-fns": "catalog:",
"gray-matter": "catalog:",
"@types/mdx": "catalog:",
Expand Down
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1668dd

Please sign in to comment.