Skip to content

Commit 9a9f4e6

Browse files
committed
chore: Add lazy loading for images in layout components
This commit adds the `Head` component from the `next/head` package to the layout components in the `2023` and `2024` apps. The `Head` component is used to add a `link` tag that preconnects to the Google Fonts API, improving the performance of font loading. Additionally, the commit updates the `next.config.js` file to fix a bug related to rewrites for the `/2024` route. The missing rewrites were causing incorrect redirection, and this commit adds the necessary rewrites to ensure proper redirection. Fixes #129
1 parent 4ab3c73 commit 9a9f4e6

File tree

4 files changed

+44
-56
lines changed

4 files changed

+44
-56
lines changed

apps/2023/app/layout.tsx

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Navbar from "@repo/ui/components/shared/2023/layout/navbar";
33
import "@repo/ui/globals.css";
44
import type { Metadata } from "next";
55
import { Inter } from "next/font/google";
6+
import Head from "next/head";
67

78
const inter = Inter({ subsets: ["latin"] });
89

@@ -18,34 +19,20 @@ export default function RootLayout({
1819
}): JSX.Element {
1920
return (
2021
<html lang="en">
21-
{/* <!-- Google tag (gtag.js) --> */}
22-
<script
23-
async
24-
src="https://www.googletagmanager.com/gtag/js?id=G-TKTWYJW41C"
25-
></script>
26-
<script>
27-
{`
28-
window.dataLayer = window.dataLayer || [];
29-
function gtag(){dataLayer.push(arguments);}
30-
gtag('js', new Date());
22+
<Head>
23+
<link rel="preconnect" href="https://fonts.googleapis.com" />
24+
<link
25+
rel="preconnect"
26+
href="https://fonts.gstatic.com"
27+
// crossOrigin={true}
28+
/>
29+
<link
30+
href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
31+
rel="stylesheet"
32+
></link>
33+
</Head>
3134

32-
gtag('config', 'G-TKTWYJW41C');
33-
`}
34-
</script>
35-
<link rel="preconnect" href="https://fonts.googleapis.com" />
36-
<link
37-
rel="preconnect"
38-
href="https://fonts.gstatic.com"
39-
// crossOrigin={true}
40-
/>
41-
<link
42-
href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
43-
rel="stylesheet"
44-
></link>
45-
46-
<body
47-
className={`flex min-h-screen flex-col justify-between`}
48-
>
35+
<body className={`flex min-h-screen flex-col justify-between`}>
4936
<Navbar />
5037
{children}
5138
<Footer />

apps/2024/app/layout.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import "@repo/ui/globals.css";
22
import type { Metadata } from "next";
33
import { Inter } from "next/font/google";
4-
import Navbar from '@repo/ui/components/shared/2024/layout/Navbar'
4+
import Navbar from "@repo/ui/components/shared/2024/layout/Navbar";
55
import Footer from "@repo/ui/components/shared/2023/layout/footer";
6+
import Head from "next/head";
67

78
const inter = Inter({ subsets: ["latin"] });
89

@@ -19,34 +20,34 @@ export default function RootLayout({
1920
}): JSX.Element {
2021
return (
2122
<html lang="en">
22-
<script
23-
async
24-
src="https://www.googletagmanager.com/gtag/js?id=G-TKTWYJW41C"
25-
></script>
26-
<script>
27-
{`
23+
<Head>
24+
<script
25+
async
26+
src="https://www.googletagmanager.com/gtag/js?id=G-TKTWYJW41C"
27+
></script>
28+
<script>
29+
{`
2830
window.dataLayer = window.dataLayer || [];
2931
function gtag(){dataLayer.push(arguments);}
3032
gtag('js', new Date());
3133
3234
gtag('config', 'G-TKTWYJW41C');
3335
`}
34-
</script>
36+
</script>
3537

36-
<link rel="preconnect" href="https://fonts.googleapis.com" />
37-
<link
38-
rel="preconnect"
39-
href="https://fonts.gstatic.com"
40-
// crossOrigin="true"
41-
/>
42-
<link
43-
href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
44-
rel="stylesheet"
45-
></link>
38+
<link rel="preconnect" href="https://fonts.googleapis.com" />
39+
<link
40+
rel="preconnect"
41+
href="https://fonts.gstatic.com"
42+
// crossOrigin="true"
43+
/>
44+
<link
45+
href="https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
46+
rel="stylesheet"
47+
></link>
48+
</Head>
4649

47-
<body
48-
className={`flex min-h-screen flex-col justify-between`}
49-
>
50+
<body className={`flex min-h-screen flex-col justify-between`}>
5051
<Navbar />
5152
{children}
5253
<Footer />

apps/2024/next.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ module.exports = {
88
ignoreBuildErrors: true,
99
},
1010
// fix the rewrites bug
11-
async rewrites() {
11+
async rewrites() {
1212
return [
1313
{
1414
source: "/2023/:path*",
15-
destination: `${process.env.NODE_ENV
15+
destination: `${(process.env.NODE_ENV || "development")
1616
=== "development" ? "http://localhost:3002" : "https://ug.pycon.org"
1717
}/:path*`,
1818
},
1919
{
2020
source: "/2023",
21-
destination: `${process.env.NODE_ENV
21+
destination: `${(process.env.NODE_ENV || "development")
2222
=== "development" ? "http://localhost:3002" : "https://ug.pycon.org"
2323
}/:path*`,
2424
},
2525
{
2626
source: "/2024/:path*",
27-
destination: `${process.env.NODE_ENV
27+
destination: `${(process.env.NODE_ENV || "development")
2828
=== "development" ? "http://localhost:3001" : "https://ug.pycon.org"
2929
}/:path*`,
3030
},
3131
{
3232
source: "/:path*",
33-
destination: `${process.env.NODE_ENV
33+
destination: `${(process.env.NODE_ENV || "development")
3434
=== "development" ? "http://localhost:3001" : "https://ug.pycon.org"
3535
}/:path*`,
3636
},

packages/ui/src/components/shared/2023/layout/footer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export default function Footer() {
5454
Health and Safety Guidelines
5555
</Link>
5656
</p>
57-
<p className="mb-4">
58-
Our PyCon Uganda Editions:
57+
<div>
58+
<p className="mb-4">Our PyCon Uganda Editions:</p>
5959
<ul className="list-disc ml-6 space-y-2 mt-2">
6060
<li className="text-sm text-blue-400 underline">
6161
<Link href="/2024">PyCon Uganda 2024</Link>
@@ -64,7 +64,7 @@ export default function Footer() {
6464
<Link href="/2023">PyCon Uganda 2023</Link>
6565
</li>
6666
</ul>
67-
</p>
67+
</div>
6868
</div>
6969
<div className="my-10">
7070
<h6 className="mb-4 flex justify-center font-semibold uppercase md:justify-start">

0 commit comments

Comments
 (0)