feature: add sv-router, page structure and redirect to home from any other page
This commit is contained in:
+5
-4
@@ -6,21 +6,22 @@
|
||||
/**
|
||||
* App Component
|
||||
*
|
||||
* Application entry point component. Wraps the main page route within the shared
|
||||
* Application entry point component. Wraps the active route within the shared
|
||||
* layout shell. This is the root component mounted by the application.
|
||||
*
|
||||
* Structure:
|
||||
* - QueryProvider provides TanStack Query client for data fetching
|
||||
* - Layout provides sidebar, header/footer, and page container
|
||||
* - Page renders the current route content
|
||||
* - Router renders the matched route component
|
||||
*/
|
||||
import Page from '$routes/Page.svelte';
|
||||
import '$routes/router';
|
||||
import { Router } from 'sv-router';
|
||||
import { QueryProvider } from './providers';
|
||||
import Layout from './ui/Layout.svelte';
|
||||
</script>
|
||||
|
||||
<QueryProvider>
|
||||
<Layout>
|
||||
<Page />
|
||||
<Router />
|
||||
</Layout>
|
||||
</QueryProvider>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--
|
||||
Component: Page
|
||||
Description: The main page component of the application.
|
||||
Component: Home
|
||||
Root route — comparison workspace.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { ComparisonView } from '$widgets/ComparisonView';
|
||||
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
Component: Redirect
|
||||
Mounts only when an unmatched route is hit; immediately replaces the URL
|
||||
with the home route. Kept until additional routes exist.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { navigate } from './router';
|
||||
|
||||
navigate('/', { replace: true });
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
export {
|
||||
isActive,
|
||||
navigate,
|
||||
p,
|
||||
preload,
|
||||
route,
|
||||
} from './router';
|
||||
@@ -0,0 +1,23 @@
|
||||
import { createRouter } from 'sv-router';
|
||||
import Home from './Home.svelte';
|
||||
import Redirect from './Redirect.svelte';
|
||||
|
||||
/**
|
||||
* Single-page router for glyphdiff.
|
||||
*
|
||||
* Currently exposes one route; structure exists so additional routes can be
|
||||
* added without touching the app shell.
|
||||
*/
|
||||
export const {
|
||||
isActive,
|
||||
navigate,
|
||||
p,
|
||||
preload,
|
||||
route,
|
||||
} = createRouter({
|
||||
'/': Home,
|
||||
/**
|
||||
* Any unmatched path redirects to home until additional routes exist.
|
||||
*/
|
||||
'*notfound': Redirect,
|
||||
});
|
||||
Reference in New Issue
Block a user