Skip to content

Commit

Permalink
feat: use resolvePageComponent in app stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Mar 2, 2024
1 parent af7fac6 commit 6f4b7f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 5 additions & 2 deletions stubs/react/app.tsx.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import './css/app.css';

import { createRoot } from 'react-dom/client';
import { createInertiaApp } from '@inertiajs/react';
import { resolvePageComponent } from '@adonisjs/inertia/helpers'

const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'

Expand All @@ -14,8 +15,10 @@ createInertiaApp({
title: (title) => {{ '`${title} - ${appName}`' }},

resolve: (name) => {
const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
{{ 'return pages[`./pages/${name}.tsx`]' }}
return resolvePageComponent(
{{ '`./pages/${name}.tsx`' }},
import.meta.glob<DefineComponent>('./pages/**/*.tsx'),
)
},

setup({ el, App, props }) {
Expand Down
9 changes: 6 additions & 3 deletions stubs/solid/app.tsx.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import './css/app.css'

import { render } from 'solid-js/web'
import { createInertiaApp } from 'inertia-adapter-solid'
import { resolvePageComponent } from '@adonisjs/inertia/helpers'

const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'

Expand All @@ -13,9 +14,11 @@ createInertiaApp({

title: (title) => {{ '`${title} - ${appName}`' }},

resolve(name) {
const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
{{ 'return pages[`./pages/${name}.tsx`]' }}
resolve: (name) => {
return resolvePageComponent(
{{ '`./pages/${name}.tsx`' }},
import.meta.glob<DefineComponent>('./pages/**/*.tsx'),
)
},

setup({ el, App, props }) {
Expand Down
7 changes: 5 additions & 2 deletions stubs/vue/app.ts.stub
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import './css/app.css';
import { createApp, h } from 'vue'
import type { DefineComponent } from 'vue'
import { createInertiaApp } from '@inertiajs/vue3'
import { resolvePageComponent } from '@adonisjs/inertia/helpers'

const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'

Expand All @@ -15,8 +16,10 @@ createInertiaApp({
title: (title) => {{ '`${title} - ${appName}`' }},

resolve: (name) => {
const pages = import.meta.glob<DefineComponent>('./pages/**/*.vue', { eager: true })
{{ 'return pages[`./pages/${name}.vue`]' }}
return resolvePageComponent(
{{ '`./pages/${name}.vue`' }},
import.meta.glob<DefineComponent>('./pages/**/*.vue'),
)
},

setup({ el, App, props, plugin }) {
Expand Down

0 comments on commit 6f4b7f5

Please sign in to comment.