Skip to content

Commit 144deb7

Browse files
committedMar 18, 2025·
feat: New structure
1 parent f763f63 commit 144deb7

File tree

16 files changed

+60
-59
lines changed

16 files changed

+60
-59
lines changed
 

‎config/build/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ const filesConfig : esbuild.BuildOptions = {
4949
sourcemap: true,
5050
sourcesContent: true,
5151
tsconfig: './deno.json',
52-
outdir: './dist',
53-
outbase: './src/client',
54-
entryNames: '[dir]/bundle',
52+
outdir: './dist/app',
53+
outbase: './src/client/app',
5554
entryPoints: [
56-
'./src/client/app/**/index.tsx'
55+
'./src/client/app/index.tsx'
5756
],
5857
supported: {
5958
'import-attributes': true,

‎src/client/app/404/index.html

-14
This file was deleted.

‎src/client/app/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Home</title>
7-
<link rel="shortcut icon" href="./assets/favicon.svg" type="image/x-icon" />
8-
<script type="module" src="./bundle.js" defer></script>
7+
<link rel="shortcut icon" href="/static/favicon.svg" type="image/x-icon" />
8+
<script type="module" src="./index.js" defer></script>
99
</head>
1010
<body id="root"></body>
1111
</html>

‎src/client/app/index.scss

-24
This file was deleted.

‎src/client/app/index.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render } from "@solid-js/web";
2+
import { Route, Router } from "@solid-js/router";
23
import { createSignal, type JSXElement } from "@solid-js";
3-
4-
import './index.scss'
4+
import { Home } from './pages/home/index.tsx';
55

66
function App() : JSXElement {
77
const [count, setCount] = createSignal(1);
@@ -10,7 +10,7 @@ function App() : JSXElement {
1010
return (
1111
<div class='app'>
1212
<h1 class='title'>Home</h1>
13-
<img class='logo' src='/-/solidjs_logo.svg' alt='SolidJS Logo' />
13+
<img class='logo' src='/static/solidjs_logo.svg' alt='SolidJS Logo' />
1414
<button type='button' onClick={increment}>
1515
{count()}
1616
</button>
@@ -22,4 +22,9 @@ const root = globalThis.document.getElementById("root")
2222
if (!root) {
2323
throw new Error('No root element found.')
2424
}
25-
render(() => <App/>, root);
25+
render(
26+
() => <Router>
27+
<Route path={["/app", "/app/", "/app/home"]} component={Home} />
28+
</Router>,
29+
root
30+
);
File renamed without changes.

‎src/client/app/pages/404/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type {JSXElement} from '@solid-js'
2+
3+
import './index.scss'
4+
5+
export function NotFound() : JSXElement {
6+
return (
7+
<div class='not-found'>
8+
<h1 class='title'>404 Not Found</h1>
9+
<img class='logo' src='/static/solidjs_logo.svg' alt='SolidJS Logo'/>
10+
</div>
11+
)
12+
}
Loading
File renamed without changes.

‎src/client/app/pages/home/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type {JSXElement} from '@solid-js'
2+
3+
import './index.scss'
4+
5+
export function Home() : JSXElement {
6+
return (
7+
<div class='home'>
8+
<h1 class='title'>Home</h1>
9+
<img class='logo' src='/static/solidjs_logo.svg' alt='SolidJS Logo'/>
10+
</div>
11+
)
12+
}
Loading

‎src/client/app/pages/settings/index.scss

Whitespace-only changes.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type {JSXElement} from '@solid-js'
2+
3+
import './index.scss'
4+
5+
export function Settings() : JSXElement {
6+
return (
7+
<div class='settings'>
8+
<h1 class='title'>Home</h1>
9+
<img class='logo' src='/static/solidjs_logo.svg' alt='SolidJS Logo'/>
10+
</div>
11+
)
12+
}

‎src/client/static/favicon.svg

+1
Loading

‎src/server/index.ts

+7-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const appDirectory = `${rootDirectory}/app/`;
66

77
const routes : Route[] = [
88
{
9-
pattern: new URLPattern({ pathname: "/-/:staticAsset*" }),
9+
pattern: new URLPattern({ pathname: "/static/:staticAsset*" }),
1010
handler: (request, _info, parameters) => pageHandler(
1111
request,
1212
rootDirectory,
@@ -15,23 +15,19 @@ const routes : Route[] = [
1515
)
1616
},
1717
{
18-
pattern: new URLPattern({ pathname: '/:page([^\.]*)' }),
18+
pattern: new URLPattern({ pathname: '/index.js' }),
1919
handler: (request, _info, parameters) => {
2020
console.log('page', parameters?.pathname.groups.page);
2121

22-
return pageHandler(request, appDirectory, '')
22+
return pageHandler(request, appDirectory, '', 'index.js')
2323
}
2424
},
2525
{
26-
pattern: new URLPattern({ pathname: '/:asset' }),
26+
pattern: new URLPattern({ pathname: '/app:page(|\/.*)' }),
2727
handler: (request, _info, parameters) => {
28-
const {asset} = parameters?.pathname.groups ?? {};
29-
return pageHandler(
30-
request,
31-
appDirectory,
32-
'',
33-
asset
34-
);
28+
console.log('page', parameters?.pathname.groups.page);
29+
30+
return pageHandler(request, appDirectory, '')
3531
}
3632
},
3733
];

0 commit comments

Comments
 (0)
Please sign in to comment.