Skip to content

Commit 8ba22e2

Browse files
committed
fix(demo): home page CTAs use TanStack Link to honor basepath
'Browse without login' and 'FHIRPath playground' were plain <a href="/patients"> tags, which on /fhir-dsl/demo sent users to https://awbx.github.io/patients (404). The navbar already used <Link> correctly; these CTAs and the FeatureCards didn't. Switched internal targets to TanStack Link so the router prepends the configured basepath.
1 parent d851033 commit 8ba22e2

1 file changed

Lines changed: 31 additions & 23 deletions

File tree

apps/his-demo/src/routes/index.tsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createFileRoute } from "@tanstack/react-router";
1+
import { Link, createFileRoute } from "@tanstack/react-router";
22
import { ArrowRight, Database, FlaskConical, MessageSquare, ShieldCheck } from "lucide-react";
33
import { Button } from "#/components/ui/button";
44
import { buildLauncherEntryUrl } from "#/lib/smart-config";
@@ -27,10 +27,10 @@ function Home() {
2727
</a>
2828
</Button>
2929
<Button asChild variant="outline" size="lg">
30-
<a href="/patients">Browse without login</a>
30+
<Link to="/patients">Browse without login</Link>
3131
</Button>
3232
<Button asChild variant="ghost" size="lg">
33-
<a href="/playground">FHIRPath playground</a>
33+
<Link to="/playground">FHIRPath playground</Link>
3434
</Button>
3535
</div>
3636
<p className="text-xs text-muted-foreground">
@@ -46,13 +46,13 @@ function Home() {
4646
icon={<Database className="h-5 w-5" />}
4747
title="Typed search builder"
4848
code={`fhir.search("Patient")\n .where("name:contains", "eq", q)\n .include("general-practitioner")\n .sort("birthdate", "desc")\n .execute();`}
49-
href="/patients"
49+
to="/patients"
5050
/>
5151
<FeatureCard
5252
icon={<FlaskConical className="h-5 w-5" />}
5353
title="FHIRPath + UCUM"
5454
code={`fhirpath<Observation>(\"Observation\")\n .valueQuantity\n .where($ => $.eq({ value: 0.005, unit: \"g\" }))\n .exists()\n .evaluate(obs); // [true]`}
55-
href="/playground"
55+
to="/playground"
5656
/>
5757
<FeatureCard
5858
icon={<ShieldCheck className="h-5 w-5" />}
@@ -72,32 +72,40 @@ function Home() {
7272
);
7373
}
7474

75-
function FeatureCard({
76-
icon,
77-
title,
78-
code,
79-
href,
80-
hint,
81-
}: {
75+
type FeatureCardProps = {
8276
icon: React.ReactNode;
8377
title: string;
8478
code: string;
85-
href: string;
8679
hint?: string;
87-
}) {
88-
return (
89-
<a
90-
href={href}
91-
className="group flex flex-col gap-3 rounded-lg border border-border bg-card p-5 transition hover:border-primary/40"
92-
>
80+
} & ({ to: "/patients" | "/playground" } | { href: string });
81+
82+
function FeatureCard(props: FeatureCardProps) {
83+
const cardClass =
84+
"group flex flex-col gap-3 rounded-lg border border-border bg-card p-5 transition hover:border-primary/40";
85+
const inner = (
86+
<>
9387
<div className="flex items-center gap-2 text-sm font-medium text-foreground">
94-
<span className="rounded bg-primary/10 p-1.5 text-primary">{icon}</span>
95-
{title}
88+
<span className="rounded bg-primary/10 p-1.5 text-primary">{props.icon}</span>
89+
{props.title}
9690
</div>
9791
<pre className="overflow-x-auto rounded bg-muted/50 p-3 text-[11px] leading-snug text-muted-foreground">
98-
<code>{code}</code>
92+
<code>{props.code}</code>
9993
</pre>
100-
{hint ? <p className="text-xs text-muted-foreground">{hint}</p> : null}
94+
{props.hint ? <p className="text-xs text-muted-foreground">{props.hint}</p> : null}
95+
</>
96+
);
97+
// Internal SPA routes go through TanStack Link so the basepath
98+
// (/fhir-dsl/demo/) is honored. External URLs and "#" stay as <a>.
99+
if ("to" in props) {
100+
return (
101+
<Link to={props.to} className={cardClass}>
102+
{inner}
103+
</Link>
104+
);
105+
}
106+
return (
107+
<a href={props.href} className={cardClass}>
108+
{inner}
101109
</a>
102110
);
103111
}

0 commit comments

Comments
 (0)