mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +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} />,
|
||||
});
|
||||
}
|
||||
36
inertia/css/app.css
Normal file
36
inertia/css/app.css
Normal file
@@ -0,0 +1,36 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap');
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
background-color: #f7f8fa;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
color: #46444c;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 42px;
|
||||
font-weight: 500;
|
||||
color: #5a45ff;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: underline;
|
||||
color: #5a45ff;
|
||||
}
|
||||
11
inertia/pages/errors/not_found.tsx
Normal file
11
inertia/pages/errors/not_found.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<>
|
||||
<div className="container">
|
||||
<div className="title">Page not found</div>
|
||||
|
||||
<span>This page does not exist.</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
11
inertia/pages/errors/server_error.tsx
Normal file
11
inertia/pages/errors/server_error.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function ServerError(props: { error: any }) {
|
||||
return (
|
||||
<>
|
||||
<div className="container">
|
||||
<div className="title">Server Error</div>
|
||||
|
||||
<span>{props.error.message}</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
18
inertia/pages/home.tsx
Normal file
18
inertia/pages/home.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Head } from '@inertiajs/react';
|
||||
|
||||
export default function Home(props: { version: number }) {
|
||||
return (
|
||||
<>
|
||||
<Head title="Homepage" />
|
||||
|
||||
<div className="container">
|
||||
<div className="title">AdonisJS {props.version} x Inertia x React</div>
|
||||
|
||||
<span>
|
||||
Learn more about AdonisJS and Inertia.js by visiting the{' '}
|
||||
<a href="https://docs.adonisjs.com/guides/inertia">AdonisJS documentation</a>.
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
12
inertia/tsconfig.json
Normal file
12
inertia/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "@adonisjs/tsconfig/tsconfig.client.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"module": "ESNext",
|
||||
"jsx": "react-jsx",
|
||||
"paths": {
|
||||
"~/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["./**/*.ts", "./**/*.tsx"]
|
||||
}
|
||||
Reference in New Issue
Block a user