link: refactor href rewrite

- uses prop instead of attempting to read env variable
- uses URL type instead of custom heuristics
This commit is contained in:
Elijah Duffy
2025-12-12 13:59:21 -08:00
parent ae3abad769
commit 3885ac09a1
4 changed files with 74 additions and 22 deletions

View File

@@ -476,6 +476,23 @@
{/snippet}
</div>
<!-- Link with href rewriting -->
<div class="component">
<p class="title">Link (with href rewriting)</p>
<p class="mb-3">
href rewriting allows you to prepend a basepath to relative links, making it easier to manage
URLs in your application. It is recommended to wrap this element with your own, e.g. AppLink,
that automatically provides the basepath from your app's configuration.
</p>
<div class="flex flex-col gap-3">
<Link href="/about" basepath="/sui-demo">Go to About Page (with basepath)</Link>
<Link href="https://svelte.dev" basepath="/sui-demo">External Svelte Site</Link>
<Link href="contact">Contact Us (relative link, no basepath)</Link>
</div>
</div>
<!-- Regular Dialog Demo -->
<Dialog
bind:open={dialogOpen}