orga-build 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app.jsx +18 -15
- package/lib/client.jsx +7 -13
- package/lib/csr.jsx +3 -3
- package/lib/ssr.jsx +6 -8
- package/package.json +6 -6
package/lib/app.jsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createElement } from 'react'
|
|
2
1
|
import pages from '@orga-build/pages'
|
|
3
2
|
import layouts from '@orga-build/layouts'
|
|
4
3
|
import * as components from '@orga-build/components'
|
|
5
|
-
import {
|
|
4
|
+
import { Route, Switch, Link } from 'wouter'
|
|
6
5
|
|
|
7
6
|
export function App() {
|
|
8
7
|
const _pages = Object.entries(pages).map(([path, page]) => {
|
|
@@ -16,19 +15,13 @@ export function App() {
|
|
|
16
15
|
const layoutIds = Object.keys(layouts)
|
|
17
16
|
.filter((key) => path.startsWith(key))
|
|
18
17
|
.sort((a, b) => -a.localeCompare(b))
|
|
19
|
-
let element =
|
|
20
|
-
components: { ...components, Link }
|
|
21
|
-
})
|
|
18
|
+
let element = <page.default components={{ ...components, Link, a: Link }} />
|
|
22
19
|
for (const layoutId of layoutIds) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
...page,
|
|
29
|
-
pages: _pages
|
|
30
|
-
},
|
|
31
|
-
element
|
|
20
|
+
const Layout = layouts[layoutId]
|
|
21
|
+
element = (
|
|
22
|
+
<Layout title={page.title} slug={path} pages={_pages} {...page}>
|
|
23
|
+
{element}
|
|
24
|
+
</Layout>
|
|
32
25
|
)
|
|
33
26
|
}
|
|
34
27
|
return {
|
|
@@ -37,5 +30,15 @@ export function App() {
|
|
|
37
30
|
}
|
|
38
31
|
})
|
|
39
32
|
|
|
40
|
-
return
|
|
33
|
+
return (
|
|
34
|
+
<Switch>
|
|
35
|
+
{pageRoutes.map((route) => {
|
|
36
|
+
return (
|
|
37
|
+
<Route key={`r-${route.path}`} path={route.path}>
|
|
38
|
+
{route.element}
|
|
39
|
+
</Route>
|
|
40
|
+
)
|
|
41
|
+
})}
|
|
42
|
+
</Switch>
|
|
43
|
+
)
|
|
41
44
|
}
|
package/lib/client.jsx
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { hydrateRoot } from 'react-dom/client'
|
|
2
|
-
import {
|
|
2
|
+
import { Router } from 'wouter'
|
|
3
3
|
import { App } from './app.jsx'
|
|
4
4
|
|
|
5
5
|
const ssr = window._ssr
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
container,
|
|
14
|
-
<BrowserRouter basename="/">
|
|
15
|
-
<App />
|
|
16
|
-
</BrowserRouter>
|
|
17
|
-
)
|
|
18
|
-
}
|
|
7
|
+
hydrateRoot(
|
|
8
|
+
document.getElementById('root'),
|
|
9
|
+
<Router>
|
|
10
|
+
<App />
|
|
11
|
+
</Router>
|
|
12
|
+
)
|
package/lib/csr.jsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { createRoot } from 'react-dom/client'
|
|
3
3
|
import { App } from './app.jsx'
|
|
4
|
-
import {
|
|
4
|
+
import { Router } from 'wouter'
|
|
5
5
|
|
|
6
6
|
const container = document.getElementById('root')
|
|
7
7
|
const root = createRoot(container)
|
|
8
8
|
root.render(
|
|
9
|
-
<
|
|
9
|
+
<Router>
|
|
10
10
|
<App />
|
|
11
|
-
</
|
|
11
|
+
</Router>
|
|
12
12
|
)
|
package/lib/ssr.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pages from '@orga-build/pages'
|
|
2
2
|
import { renderToString } from 'react-dom/server'
|
|
3
|
-
import { StaticRouter } from 'react-router'
|
|
4
3
|
import { App } from './app.jsx'
|
|
4
|
+
import { Router } from 'wouter'
|
|
5
5
|
|
|
6
6
|
export { pages }
|
|
7
7
|
|
|
@@ -14,13 +14,11 @@ export function render(url) {
|
|
|
14
14
|
console.log(`no page found for ${url}`)
|
|
15
15
|
return
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<StaticRouter location={url}>
|
|
17
|
+
const ssrContext = {}
|
|
18
|
+
console.log(`rendering ${url}`)
|
|
19
|
+
return renderToString(
|
|
20
|
+
<Router ssrPath={url} ssrContext={ssrContext}>
|
|
23
21
|
<App />
|
|
24
|
-
</
|
|
22
|
+
</Router>
|
|
25
23
|
)
|
|
26
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orga-build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A simple tool that builds org-mode files into a website",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,13 +34,10 @@
|
|
|
34
34
|
"esbuild": "^0.24.2",
|
|
35
35
|
"express": "^5.1.0",
|
|
36
36
|
"globby": "^14.1.0",
|
|
37
|
-
"react": "^19.0.0",
|
|
38
|
-
"react-dom": "^19.0.0",
|
|
39
|
-
"react-router": "^7.5.1",
|
|
40
37
|
"rehype-katex": "^7.0.1",
|
|
41
|
-
"serve-handler": "^6.1.6",
|
|
42
38
|
"unist-util-visit-parents": "^6.0.1",
|
|
43
39
|
"vite": "6.3.2",
|
|
40
|
+
"wouter": "^3.7.0",
|
|
44
41
|
"@orgajs/esbuild": "^1.1.3",
|
|
45
42
|
"@orgajs/node-loader": "^1.1.3",
|
|
46
43
|
"@orgajs/rollup": "1.3.2"
|
|
@@ -51,9 +48,12 @@
|
|
|
51
48
|
"@types/node": "^22.13.1",
|
|
52
49
|
"@types/react": "^19.0.8",
|
|
53
50
|
"@types/react-dom": "^19.0.3",
|
|
54
|
-
"@types/serve-handler": "^6.1.4",
|
|
55
51
|
"@orgajs/orgx": "^2.5.2",
|
|
56
52
|
"orga": "^4.5.1"
|
|
57
53
|
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "^19.0.0",
|
|
56
|
+
"react-dom": "^19.0.0"
|
|
57
|
+
},
|
|
58
58
|
"scripts": {}
|
|
59
59
|
}
|