Skip to content

Commit 5310ca8

Browse files
committed
chore: Rename demo folder to playground.
This is to free up the "demo" name for a clean demo.
1 parent 9d8193f commit 5310ca8

File tree

80 files changed

+120
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+120
-77
lines changed

demo/README.md

Lines changed: 0 additions & 45 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

playground/README.md

Lines changed: 51 additions & 0 deletions
File renamed without changes.

demo/package-lock.json renamed to playground/package-lock.json

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/package.json renamed to playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "svelte-router-demo",
2+
"name": "svelte-router-playground",
33
"private": true,
44
"version": "0.1.0",
55
"type": "module",
File renamed without changes.

demo/src/App.svelte renamed to playground/src/App.svelte

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
import './app.scss';
33
import NavBar from './lib/NavBar.svelte';
44
import Tooltip from './lib/Tooltip.svelte';
5-
import { Router, Route, Fallback, RouterTrace, Redirector } from '@svelte-router/core';
5+
import {
6+
Router,
7+
Route,
8+
Fallback,
9+
RouterTrace,
10+
Redirector,
11+
location,
12+
buildHref
13+
} from '@svelte-router/core';
14+
import { calculateHref, calculateState } from '@svelte-router/core/kernel';
615
import NotFound from './lib/NotFound.svelte';
716
import HomeView from './lib/views/home/HomeView.svelte';
817
import PathRoutingView from './lib/views/path-routing/PathRoutingView.svelte';
@@ -11,16 +20,23 @@
1120
import { initTitleContext } from './lib/state/title.svelte';
1221
import HrInCodeView from './lib/views/hash-routing/InCodeView.svelte';
1322
import RedirectedView from './lib/views/redirected/RedirectedView.svelte';
23+
import { routingMode } from './lib/hash-routing';
1424
1525
initTitleContext();
1626
let showNavTooltip = $state(false);
27+
const redirectedHash = routingMode === 'multi' ? 'redir' : true;
1728
const redirector = new Redirector();
1829
redirector.redirections.push({
1930
pattern: '/deprecated-path',
20-
href: '/new-path',
31+
href: () => {
32+
const pathnamePiece = calculateHref({ hash: false }, '/feat');
33+
const hashPiece = calculateHref({ hash: redirectedHash }, '/new-path');
34+
return buildHref(pathnamePiece, hashPiece);
35+
},
2136
options: {
22-
state: { redirected: true },
23-
}
37+
state: calculateState(redirectedHash, { redirected: true })
38+
},
39+
goTo: true
2440
});
2541
2642
// Show tooltip after a short delay when app loads
@@ -44,7 +60,7 @@
4460
<div class="app">
4561
<div class="d-flex flex-column h-100">
4662
<Router id="root">
47-
{#snippet children(_, rs)}
63+
{#snippet children({ rs })}
4864
<header>
4965
<Tooltip shown={showNavTooltip} placement="bottom">
5066
{#snippet reference(ref)}
@@ -69,10 +85,12 @@
6985
<Route key="hr-in-code" path="/hash-routing/in-code">
7086
<HrInCodeView />
7187
</Route>
72-
<Route key="redirected" path="/new-path">
73-
<RedirectedView />
74-
</Route>
75-
<Fallback>
88+
<Router hash={redirectedHash} id="redirector-router">
89+
<Route hash={redirectedHash} key="redirected" path="/new-path">
90+
<RedirectedView />
91+
</Route>
92+
</Router>
93+
<Fallback when={(_, nm) => nm && !location.path.startsWith('/feat')}>
7694
<NotFound />
7795
</Fallback>
7896
</div>
File renamed without changes.

0 commit comments

Comments
 (0)