Skip to content

Commit

Permalink
ssr.js layout fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkumarthakur60 committed Apr 23, 2024
1 parent e2b3be8 commit a64b928
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions resources/js/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ import { createSSRApp, h } from 'vue'
import { renderToString } from '@vue/server-renderer'
import { createInertiaApp } from '@inertiajs/vue3'
import createServer from '@inertiajs/vue3/server'
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
import layout from '@/Shared/Layout.vue'

createServer((page) => createInertiaApp({
page,
render: renderToString,
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
return pages[`./Pages/${name}.vue`]
},
title: title => title ? `${title} - Ping CRM` : 'Ping CRM',
setup({ app, props, plugin }) {
return createSSRApp({
render: () => h(app, props),
}).use(plugin)
},
page,
render: renderToString,
resolve: async (name) => {
const page = await resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue'))
const pageWithoutLayout = ['Auth/Login', 'Auth/TwoFactor']
if (!pageWithoutLayout.includes(name)) {
page.default.layout ??= layout
}
return page
},
title: title => title ? `${title} - Ping CRM` : 'Ping CRM',
setup({ app, props, plugin }) {
return createSSRApp({
render: () => h(app, props),
}).use(plugin)
},
}))

0 comments on commit a64b928

Please sign in to comment.