honox 0.1.47 → 0.1.48

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.
@@ -69,18 +69,6 @@ const createApp = (options) => {
69
69
  }
70
70
  });
71
71
  }
72
- const rendererPaths = getPaths(dir, rendererList);
73
- rendererPaths.map((path) => {
74
- const renderer = RENDERER_FILE[path];
75
- const importingIslands = renderer[IMPORTING_ISLANDS_ID];
76
- if (importingIslands) {
77
- hasIslandComponent = true;
78
- }
79
- const rendererDefault = renderer.default;
80
- if (rendererDefault) {
81
- subApp.all("*", rendererDefault);
82
- }
83
- });
84
72
  const escapeDir = (directory) => directory.replaceAll("[", "\\[").replaceAll("]", "\\]").replaceAll("(", "\\(").replaceAll(")", "\\)");
85
73
  const findMiddleware = (directory) => Object.keys(MIDDLEWARE_FILE).find(
86
74
  (x) => new RegExp(escapeDir(directory) + "/_middleware.tsx?").test(x)
@@ -95,6 +83,30 @@ const createApp = (options) => {
95
83
  (ancestorDir) => appliedMiddlewaresByDirectory.get(ancestorDir)?.has(middlewarePath)
96
84
  );
97
85
  };
86
+ const rendererPaths = getPaths(dir, rendererList);
87
+ rendererPaths.map((path) => {
88
+ const renderer = RENDERER_FILE[path];
89
+ const importingIslands = renderer[IMPORTING_ISLANDS_ID];
90
+ if (importingIslands) {
91
+ hasIslandComponent = true;
92
+ }
93
+ const rendererDefault = renderer.default;
94
+ if (rendererDefault) {
95
+ subApp.use("*", rendererDefault);
96
+ const rootPath2 = dir.replace(rootRegExp, "");
97
+ const isRootLevel = !rootPath2.includes("/") || rootPath2 === "";
98
+ const isSimpleStructure = Object.keys(content).length <= 4 && !Object.keys(content).some((f) => f.includes("/"));
99
+ if (Object.keys(content).length > 0 && isRootLevel && isSimpleStructure) {
100
+ subApp.use("/", rendererDefault);
101
+ Object.keys(content).forEach((filename) => {
102
+ const path2 = filePathToPath(filename);
103
+ if (path2 !== "/" && !path2.includes("[") && !path2.includes("*")) {
104
+ subApp.use(path2, rendererDefault);
105
+ }
106
+ });
107
+ }
108
+ }
109
+ });
98
110
  let middlewareFile = findMiddleware(dir);
99
111
  if (!middlewareFile) {
100
112
  const dirParts = dir.split("/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honox",
3
- "version": "0.1.47",
3
+ "version": "0.1.48",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "scripts": {