{@render globalState.title?.()}
search - +
{@render children()} diff --git a/resources/js/Library/PassState.svelte.ts b/resources/js/Library/PassState.svelte.ts index 0833f99..769a2fd 100644 --- a/resources/js/Library/PassState.svelte.ts +++ b/resources/js/Library/PassState.svelte.ts @@ -1,5 +1,9 @@ +import type { Snippet } from 'svelte'; + export const globalState: { - title?: any + title?: Snippet; + searchQuery?: string; } = $state({ }) + diff --git a/resources/js/Pages/Home.svelte b/resources/js/Pages/Home.svelte index b463ef8..92d7b71 100644 --- a/resources/js/Pages/Home.svelte +++ b/resources/js/Pages/Home.svelte @@ -1,5 +1,5 @@ + + + + + Search {globalState.searchQuery} - {appName} + + +{#snippet title()} +

Search

+{/snippet} diff --git a/resources/js/app.ts b/resources/js/app.ts index 2c4f577..54daab6 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -1,5 +1,5 @@ import './bootstrap'; -import '../css/app.scss'; +import '@css/app.scss'; import { createInertiaApp, ResolvedComponent } from '@inertiajs/svelte'; import { hydrate, mount } from 'svelte'; diff --git a/routes/web.php b/routes/web.php index 32f95e3..1de70bd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,3 +6,7 @@ use Inertia\Inertia; Route::get('/', function () { return Inertia::render('Home'); })->name('home'); + +Route::get('/search', function () { + return Inertia::render('Search'); +})->name('search'); diff --git a/tsconfig.json b/tsconfig.json index 5823e3b..635ea18 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,8 @@ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ "paths": { "@/*": ["./resources/js/*"], + "@components/*": ["./resources/js/Components/*"], + "@css/*": ["./resources/css/*"], "ziggy-js": ["./vendor/tightenco/ziggy"] } /* Specify a set of entries that re-map imports to additional lookup locations. */, // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ diff --git a/vite.config.js b/vite.config.js index 87b4ffe..35b011c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -24,6 +24,14 @@ export default defineConfig({ { find: 'ziggy-js', replacement: path.resolve(__dirname, 'vendor/tightenco/ziggy/'), + }, + { + find: '@css', + replacement: path.resolve(__dirname, 'resources/css'), + }, + { + find: '@components', + replacement: path.resolve(__dirname, 'resources/js/Components'), } ] }