Having trouble with the persistent/default Layout Example from Inertia Website #879
Replies: 2 comments 1 reply
-
Hey there, I don't have any time today to look at this, but I recommend looking at our Svelte implementation of the Ping CRM demo app: https://github.com/inertiajs/pingcrm-svelte. Maybe it will give you some hints of what's going wrong. 👍 |
Beta Was this translation helpful? Give feedback.
-
I was having issues trying to figure out how to get this to work in Svelte as well, but after seeing what the pingcrm-svelte repo is doing, it made sense. So for anyone else who Googles and finds this issue -
The reason for this is that per the Svelte docs, But if you're doing something like Another way to do this would be in the import { createInertiaApp } from '@inertiajs/svelte'
import { SharedLayout } from './Shared/Layout.svelte';
createInertiaApp({
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true })
let page = pages['./Pages/${name}.svelte']
page.layout = SharedLayout
return page
},
setup({ el, App, props }) {
new App({ target: el, props })
},
}) |
Beta Was this translation helpful? Give feedback.
-
I am trying to use the persistent layouts with the latest versions of Svelte and Inertiajs.
package.json
Without the persistent layouts everything (besides some annoying dev warnings) works as expected.
As soon as I add the persistent layouts to my
app.js
resolve function, only the layout will be rendered.My Welcome Page/Component is completly ignored.
app.js
Shared/Layout.svelte
Pages/Welcome.svelte
I am new to svelte, so I really do not know what I am doing wrong ¯\_(ツ)_/¯
I looked at the pingcrm-svelte project, but this does not use default/persistent layouts (as far as I can tell) and the svelte/inertia versions are older.
I have created a test repo for reproduction and testing.
Please see the commit messages for more info.
Beta Was this translation helpful? Give feedback.
All reactions