Skip to content

Commit

Permalink
Port to Next.js 15
Browse files Browse the repository at this point in the history
  • Loading branch information
torokati44 committed Nov 13, 2024
1 parent 801c0cb commit 6fc34dd
Show file tree
Hide file tree
Showing 8 changed files with 698 additions and 473 deletions.
1,112 changes: 653 additions & 459 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"@mantine/charts": "^7.14.0",
"@mantine/core": "7.14.0",
"@mantine/hooks": "7.14.0",
"@next/bundle-analyzer": "^14.2.15",
"@next/bundle-analyzer": "15.0.3",
"@tabler/icons-react": "^3.22.0",
"next": "14.2.15",
"next": "15.0.3",
"node-html-parser": "^6.1.13",
"react": "^18",
"react-device-detect": "^2.2.3",
Expand All @@ -31,7 +31,7 @@
"@typescript-eslint/parser": "^8.14.0",
"d3": "^7.9.0",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.15",
"eslint-config-next": "15.0.3",
"eslint-config-prettier": "^9.1.0",
"feed": "^4.2.2",
"gray-matter": "^4.0.3",
Expand Down
10 changes: 5 additions & 5 deletions src/app/blog/[year]/[month]/[day]/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { Container } from "@mantine/core";
import { BlogPost } from "@/app/blog/post";
import { Metadata } from "next";

export async function generateMetadata({
params,
}: {
params: PostPath;
export async function generateMetadata(props: {
params: Promise<PostPath>;
}): Promise<Metadata> {
const params = await props.params;
const post = getPostData(
`${params.year}-${params.month}-${params.day}-${params.slug}.markdown`,
);
Expand All @@ -28,7 +27,8 @@ export async function generateMetadata({
};
}

export default function Page({ params }: { params: PostPath }) {
export default async function Page(props: { params: Promise<PostPath> }) {
const params = await props.params;
const post = getPostData(
`${params.year}-${params.month}-${params.day}-${params.slug}.markdown`,
);
Expand Down
2 changes: 2 additions & 0 deletions src/app/compatibility/avm2/tree.svg/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,5 @@ export async function GET() {
},
});
}

export const dynamic = "force-static";
2 changes: 2 additions & 0 deletions src/app/feed.xml/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export async function GET() {
},
});
}

export const dynamic = "force-static";
12 changes: 11 additions & 1 deletion src/app/installers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon, IconBrandJavascript, IconList } from "@tabler/icons-react";
import React from "react";
import { useDeviceSelectors } from "react-device-detect";
import classes from "./index.module.css";
import { Button, Group } from "@mantine/core";
import { Button, Container, Group, Loader } from "@mantine/core";
import Link from "next/link";
import { allLinks, CurrentDevice, GithubRelease } from "@/app/downloads/config";

Expand All @@ -17,10 +17,20 @@ interface RecommendedDownload {
}

export default function Installers({
loading,
release,
}: {
loading: boolean;
release: GithubRelease | null;
}) {
if (loading) {
return (
<Container size="xl" className={classes.container}>
<Loader />
</Container>
);
}

const [selectors] = useDeviceSelectors(window.navigator.userAgent);
const recommended: RecommendedDownload[] = [];
const currentDevice: CurrentDevice = {
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function RootLayout({
children: React.ReactNode;
}) {
return (
<html lang="en">
<html lang="en" suppressHydrationWarning>
<head>
<ColorSchemeScript />
{/*<link rel="shortcut icon" href="/favicon.svg" />*/}
Expand Down
25 changes: 21 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import dynamic from "next/dynamic";
import classes from "./index.module.css";
import {
Expand All @@ -13,6 +15,7 @@ import Image from "next/image";
import { IconCheck } from "@tabler/icons-react";
import React from "react";
import { getLatestReleases } from "@/app/downloads/github";
import { GithubRelease } from "./downloads/config";

const InteractiveLogo = dynamic(() => import("../components/logo"), {
ssr: false,
Expand All @@ -22,9 +25,23 @@ const Installers = dynamic(() => import("./installers"), {
ssr: false,
});

export default async function Home() {
const releases = await getLatestReleases();
const latest = releases.length > 0 ? releases[0] : null;
export default function Home() {
const [latest, setLatest] = React.useState<GithubRelease | null>(null);
const [loading, setLoading] = React.useState(true);

React.useEffect(() => {
const fetchReleases = async () => {
try {
const releases = await getLatestReleases();
setLatest(releases.length > 0 ? releases[0] : null);
} catch (err) {
console.warn("Failed to fetch releases", err);
} finally {
setLoading(false);
}
};
fetchReleases();
}, []);

return (
<Container size="xl" className={classes.container}>
Expand Down Expand Up @@ -79,7 +96,7 @@ export default async function Home() {
</ListItem>
</List>

<Installers release={latest} />
<Installers loading={loading} release={latest} />
</div>
</div>
</Container>
Expand Down

0 comments on commit 6fc34dd

Please sign in to comment.