create-croissant 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { createFileRoute } from "@tanstack/react-router"
|
|
2
|
+
import { orpc } from "../lib/orpc"
|
|
2
3
|
|
|
3
4
|
export const Route = createFileRoute("/isr")({
|
|
4
|
-
loader: () => {
|
|
5
|
+
loader: async () => {
|
|
5
6
|
// In a real ISR scenario, this would be cached on the server
|
|
6
|
-
// For this example, we'll
|
|
7
|
+
// For this example, we'll fetch planets via oRPC
|
|
8
|
+
const planets = await orpc.getPlanets()
|
|
9
|
+
|
|
7
10
|
return {
|
|
8
11
|
generatedAt: new Date().toISOString(),
|
|
12
|
+
planets,
|
|
9
13
|
message: "This page is an example of ISR. In a production build with proper configuration, this data would be cached and updated in the background.",
|
|
10
14
|
}
|
|
11
15
|
},
|
|
@@ -13,17 +17,32 @@ export const Route = createFileRoute("/isr")({
|
|
|
13
17
|
})
|
|
14
18
|
|
|
15
19
|
function ISRExample() {
|
|
16
|
-
const { generatedAt, message } = Route.useLoaderData()
|
|
20
|
+
const { generatedAt, message, planets } = Route.useLoaderData()
|
|
17
21
|
|
|
18
22
|
return (
|
|
19
23
|
<div className="flex flex-col gap-4">
|
|
20
|
-
<h1 className="text-2xl font-bold">ISR Example</h1>
|
|
24
|
+
<h1 className="text-2xl font-bold">ISR Example + oRPC</h1>
|
|
21
25
|
<p>{message}</p>
|
|
22
26
|
|
|
23
27
|
<div className="rounded-lg border p-4">
|
|
24
|
-
<h2 className="font-semibold">Generated At:</h2>
|
|
28
|
+
<h2 className="font-semibold">Generated At (Server-side):</h2>
|
|
25
29
|
<p className="font-mono">{generatedAt}</p>
|
|
26
30
|
</div>
|
|
31
|
+
|
|
32
|
+
<div className="rounded-lg border p-4">
|
|
33
|
+
<h2 className="font-semibold mb-4">Planets (Fetched via oRPC):</h2>
|
|
34
|
+
{planets.length === 0 ? (
|
|
35
|
+
<p className="text-gray-500 italic">No planets found.</p>
|
|
36
|
+
) : (
|
|
37
|
+
<ul className="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
|
38
|
+
{planets.map((planet) => (
|
|
39
|
+
<li key={planet.id} className="rounded-md border p-3 bg-muted/50">
|
|
40
|
+
<span className="font-bold">{planet.name}</span> - {planet.description}
|
|
41
|
+
</li>
|
|
42
|
+
))}
|
|
43
|
+
</ul>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
27
46
|
|
|
28
47
|
<p className="text-sm text-muted-foreground">
|
|
29
48
|
Refresh the page to see if the time updates. In a true ISR setup, it would only update after a certain interval.
|