honox 0.1.38 → 0.1.39
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/README.md +8 -6
- package/dist/server/server.js +24 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -325,11 +325,13 @@ Define the middleware:
|
|
|
325
325
|
import { createRoute } from 'honox/factory'
|
|
326
326
|
import { secureHeaders, NONCE } from 'hono/secure-headers'
|
|
327
327
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
328
|
+
export default createRoute(
|
|
329
|
+
secureHeaders({
|
|
330
|
+
contentSecurityPolicy: {
|
|
331
|
+
scriptSrc: [NONCE],
|
|
332
|
+
},
|
|
333
|
+
})
|
|
334
|
+
)
|
|
333
335
|
```
|
|
334
336
|
|
|
335
337
|
You can get the `nonce` value with `c.get('secureHeadersNonce')`:
|
|
@@ -655,7 +657,7 @@ Given that HonoX is Vite-centric, if you wish to utilize [Tailwind CSS](https://
|
|
|
655
657
|
Write `app/style.css`, you must set the base path for source detection explicitly:
|
|
656
658
|
|
|
657
659
|
```css
|
|
658
|
-
@import
|
|
660
|
+
@import 'tailwindcss' source('../app');
|
|
659
661
|
```
|
|
660
662
|
|
|
661
663
|
Import it in a renderer file. Using the `Link` component will refer to the correct CSS file path after it is built.
|
package/dist/server/server.js
CHANGED
|
@@ -54,6 +54,20 @@ const createApp = (options) => {
|
|
|
54
54
|
for (const [dir, content] of Object.entries(map)) {
|
|
55
55
|
const subApp = new Hono();
|
|
56
56
|
let hasIslandComponent = false;
|
|
57
|
+
const notFoundHandler = getNotFoundHandler(dir, notFoundMap);
|
|
58
|
+
if (notFoundHandler) {
|
|
59
|
+
subApp.use(async (c, next) => {
|
|
60
|
+
await next();
|
|
61
|
+
if (c.res.status === 404) {
|
|
62
|
+
const notFoundResponse = await notFoundHandler(c);
|
|
63
|
+
const res = new Response(notFoundResponse.body, {
|
|
64
|
+
status: 404,
|
|
65
|
+
headers: notFoundResponse.headers
|
|
66
|
+
});
|
|
67
|
+
c.res = res;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
57
71
|
const rendererPaths = getPaths(dir, rendererList);
|
|
58
72
|
rendererPaths.map((path) => {
|
|
59
73
|
const renderer = RENDERER_FILE[path];
|
|
@@ -136,6 +150,16 @@ const createApp = (options) => {
|
|
|
136
150
|
}
|
|
137
151
|
return app;
|
|
138
152
|
};
|
|
153
|
+
function getNotFoundHandler(dir, map) {
|
|
154
|
+
for (const [mapDir, content] of Object.entries(map)) {
|
|
155
|
+
if (dir === mapDir) {
|
|
156
|
+
const notFound = content[NOTFOUND_FILENAME];
|
|
157
|
+
if (notFound) {
|
|
158
|
+
return notFound.default;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
139
163
|
function applyNotFound(app, dir, map) {
|
|
140
164
|
for (const [mapDir, content] of Object.entries(map)) {
|
|
141
165
|
if (dir === mapDir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "honox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
"hono": ">=4.*"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@hono/eslint-config": "^1.
|
|
130
|
+
"@hono/eslint-config": "^1.1.1",
|
|
131
131
|
"@mdx-js/rollup": "^3.0.0",
|
|
132
132
|
"@playwright/test": "^1.42.0",
|
|
133
133
|
"@types/node": "^20.10.5",
|
|
134
|
-
"eslint": "^9.
|
|
134
|
+
"eslint": "^9.23.0",
|
|
135
135
|
"glob": "^10.3.10",
|
|
136
136
|
"happy-dom": "^15.11.6",
|
|
137
137
|
"hono": "4.4.13",
|