nicer list
This commit is contained in:
18
apps/web/src/entry-server.ts
Normal file
18
apps/web/src/entry-server.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import {
|
||||||
|
createStartHandler,
|
||||||
|
defaultStreamHandler,
|
||||||
|
} from "@tanstack/react-start/server";
|
||||||
|
|
||||||
|
const handler = createStartHandler(defaultStreamHandler);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async fetch(request: Request): Promise<Response> {
|
||||||
|
const response = await handler(request);
|
||||||
|
response.headers.set(
|
||||||
|
"Cross-Origin-Embedder-Policy",
|
||||||
|
"credentialless",
|
||||||
|
);
|
||||||
|
response.headers.set("Cross-Origin-Opener-Policy", "same-origin");
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { timelinesQueryOptions } from "@/functions/get-timelines";
|
import { timelinesQueryOptions } from "@/functions/get-timelines";
|
||||||
|
|
||||||
@@ -12,13 +12,27 @@ export const Route = createFileRoute("/_default/timelines")({
|
|||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
const timelinesQuery = useSuspenseQuery(timelinesQueryOptions());
|
const timelinesQuery = useSuspenseQuery(timelinesQueryOptions());
|
||||||
return (
|
return (
|
||||||
<div>
|
<section className="container mx-auto max-w-3xl px-4 py-2">
|
||||||
<h1>List of timelines</h1>
|
<h1 className="text-4xl font-serif font-bold mb-6">Timelines</h1>
|
||||||
<div>
|
{timelinesQuery.data.length === 0 ? (
|
||||||
|
<p className="text-muted-foreground">No timelines yet.</p>
|
||||||
|
) : (
|
||||||
|
<div className="space-y-3">
|
||||||
{timelinesQuery.data.map((t) => (
|
{timelinesQuery.data.map((t) => (
|
||||||
<div key={t.id}>{t.title}</div>
|
<Link
|
||||||
|
key={t.id}
|
||||||
|
to="/timeline/$timelineId"
|
||||||
|
params={{ timelineId: t.id }}
|
||||||
|
className="block border border-border rounded-lg p-4 hover:bg-accent transition-colors"
|
||||||
|
>
|
||||||
|
<h2 className="font-serif font-bold">{t.title}</h2>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{new Date(t.createdAt).toLocaleDateString()}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,19 @@ import { defineConfig } from "vite";
|
|||||||
import tsconfigPaths from "vite-tsconfig-paths";
|
import tsconfigPaths from "vite-tsconfig-paths";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [tsconfigPaths(), tailwindcss(), tanstackStart(), viteReact()],
|
plugins: [
|
||||||
|
tsconfigPaths(),
|
||||||
|
tailwindcss(),
|
||||||
|
tanstackStart({
|
||||||
|
server: { entry: "./entry-server.ts" },
|
||||||
|
}),
|
||||||
|
viteReact(),
|
||||||
|
],
|
||||||
server: {
|
server: {
|
||||||
port: 3001,
|
port: 3001,
|
||||||
|
headers: {
|
||||||
|
"Cross-Origin-Embedder-Policy": "credentialless",
|
||||||
|
"Cross-Origin-Opener-Policy": "same-origin",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user