Skip to content

Commit

Permalink
feat: use suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwitzko committed Oct 16, 2023
1 parent 1309df2 commit 84ecb60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/layout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
.heading > a:hover {
text-decoration: none;
}

.loading {
height: 50vh;
}
22 changes: 20 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import { PluginOverview } from "@/app/client";
import { Flex, Text } from "@radix-ui/themes";
import { Suspense } from "react";

import { getAllPlugins } from "@/lib/registry";

import { PluginOverview } from "./client";
import style from "./layout.module.css";

export const revalidate = 300;

function Loading() {
return (
<Flex align="center" justify="center" className={style.loading}>
<Text>Loading...</Text>
</Flex>
);
}

export default async function Home() {
const plugins = await getAllPlugins();
plugins.sort((a, b) => a.FullName.localeCompare(b.FullName));
return <PluginOverview plugins={plugins} />;
return (
<Suspense fallback={<Loading />}>
<PluginOverview plugins={plugins} />
</Suspense>
);
}

0 comments on commit 84ecb60

Please sign in to comment.