mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
chore: init adonis
This commit is contained in:
20
inertia/app/app.tsx
Normal file
20
inertia/app/app.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import '../css/app.css';
|
||||
import { hydrateRoot } from 'react-dom/client';
|
||||
import { createInertiaApp } from '@inertiajs/react';
|
||||
import { resolvePageComponent } from '@adonisjs/inertia/helpers';
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS';
|
||||
|
||||
createInertiaApp({
|
||||
progress: { color: '#5468FF' },
|
||||
|
||||
title: (title) => `${title} - ${appName}`,
|
||||
|
||||
resolve: (name) => {
|
||||
return resolvePageComponent(`../pages/${name}.tsx`, import.meta.glob('../pages/**/*.tsx'));
|
||||
},
|
||||
|
||||
setup({ el, App, props }) {
|
||||
hydrateRoot(el, <App {...props} />);
|
||||
},
|
||||
});
|
||||
14
inertia/app/ssr.tsx
Normal file
14
inertia/app/ssr.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import ReactDOMServer from 'react-dom/server';
|
||||
import { createInertiaApp } from '@inertiajs/react';
|
||||
|
||||
export default function render(page: any) {
|
||||
return createInertiaApp({
|
||||
page,
|
||||
render: ReactDOMServer.renderToString,
|
||||
resolve: (name) => {
|
||||
const pages = import.meta.glob('../pages/**/*.tsx', { eager: true });
|
||||
return pages[`../pages/${name}.tsx`];
|
||||
},
|
||||
setup: ({ App, props }) => <App {...props} />,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user