diff --git a/examples/21_create-pages/src/entries.tsx b/examples/21_create-pages/src/entries.tsx
index df3020ef7..e214e5a41 100644
--- a/examples/21_create-pages/src/entries.tsx
+++ b/examples/21_create-pages/src/entries.tsx
@@ -1,4 +1,4 @@
-import { createPages } from 'waku';
+import { new_createPages } from 'waku';
import type { PathsForPages } from 'waku/router';
import FooPage from './components/FooPage';
@@ -9,93 +9,93 @@ import NestedBazPage from './components/NestedBazPage';
import NestedQuxPage from './components/NestedQuxPage';
import Root from './components/Root';
-const pages = createPages(async ({ createPage, createLayout, createRoot }) => [
- createRoot({
- render: 'static',
- component: Root,
- }),
+const pages = new_createPages(
+ async ({ createPage, createLayout, createRoot }) => [
+ createRoot({
+ render: 'static',
+ component: Root,
+ }),
- createLayout({
- render: 'static',
- path: '/',
- component: HomeLayout,
- }),
+ createLayout({
+ render: 'static',
+ path: '/',
+ component: HomeLayout,
+ }),
- createPage({
- render: 'static',
- // render: 'dynamic',
- path: '/',
- component: HomePage,
- }),
+ createPage({
+ render: 'static',
+ path: '/',
+ component: HomePage,
+ }),
- createPage({
- render: 'static',
- // render: 'dynamic',
- path: '/foo',
- component: FooPage,
- }),
+ createPage({
+ render: 'static',
+ path: '/foo',
+ component: FooPage,
+ }),
- createPage({
- render: 'static',
- path: '/bar',
- component: BarPage,
- }),
+ createPage({
+ render: 'static',
+ path: '/bar',
+ component: BarPage,
+ }),
- createPage({
- render: 'dynamic',
- path: '/baz',
- // Inline component is also possible.
- component: () =>
Dynamic: Baz
,
- }),
+ createPage({
+ render: 'dynamic',
+ path: '/baz',
+ // Inline component is also possible.
+ component: () => Dynamic: Baz
,
+ }),
- createPage({
- render: 'static',
- path: '/nested/baz',
- component: NestedBazPage,
- }),
+ createPage({
+ render: 'static',
+ path: '/nested/baz',
+ component: NestedBazPage,
+ }),
- createPage({
- render: 'static',
- path: '/nested/qux',
- component: NestedQuxPage,
- }),
+ createPage({
+ render: 'static',
+ path: '/nested/qux',
+ component: NestedQuxPage,
+ }),
- createPage({
- render: 'static',
- path: '/nested/[id]',
- staticPaths: ['foo', 'bar'],
- component: ({ id }) => (
- <>
- Nested
- Static: {id}
- >
- ),
- }),
+ createPage({
+ render: 'static',
+ path: '/nested/[id]',
+ staticPaths: ['foo', 'bar'],
+ component: ({ id }) => (
+ <>
+ Nested
+ Static: {id}
+ >
+ ),
+ }),
- createPage({
- render: 'dynamic',
- path: '/nested/[id]',
- component: ({ id }) => (
- <>
- Nested
- Dynamic: {id}
- >
- ),
- }),
+ createPage({
+ render: 'dynamic',
+ path: '/nested/[id]',
+ component: ({ id }) => (
+ <>
+ Nested
+ Dynamic: {id}
+ >
+ ),
+ }),
- createPage({
- render: 'dynamic',
- path: '/any/[...all]',
- component: ({ all }) => Catch-all: {all.join('/')}
,
- }),
+ createPage({
+ render: 'dynamic',
+ path: '/any/[...all]',
+ component: ({ all }) => Catch-all: {all.join('/')}
,
+ }),
- // Custom Not Found page
- createPage({
- render: 'static',
- path: '/404',
- component: () => Not Found
,
- }),
-]);
+ // Custom Not Found page
+ createPage({
+ render: 'static',
+ path: '/404',
+ component: () => Not Found
,
+ }),
+ ],
+);
declare module 'waku/router' {
interface RouteConfig {
diff --git a/packages/waku/src/main.react-server.ts b/packages/waku/src/main.react-server.ts
index f0e68761f..ceecbfc45 100644
--- a/packages/waku/src/main.react-server.ts
+++ b/packages/waku/src/main.react-server.ts
@@ -1,5 +1,5 @@
export { Link, useRouter_UNSTABLE } from 'waku/router/client';
-export { createPages } from 'waku/router/server';
+export { createPages, new_createPages } from 'waku/router/server';
export { getEnv } from 'waku/server';
diff --git a/packages/waku/src/main.ts b/packages/waku/src/main.ts
index c93f57a0f..43d696946 100644
--- a/packages/waku/src/main.ts
+++ b/packages/waku/src/main.ts
@@ -2,6 +2,7 @@ export { Link, useRouter_UNSTABLE } from 'waku/router/client';
import type {
createPages as createPagesType,
+ new_createPages as new_createPagesType,
getEnv as getEnvType,
} from './main.react-server.js';
@@ -11,6 +12,12 @@ export const createPages: typeof createPagesType = () => {
);
};
+export const new_createPages: typeof new_createPagesType = () => {
+ throw new Error(
+ '`new_createPagesType` is only available in react-server environment',
+ );
+};
+
export const getEnv: typeof getEnvType = () => {
throw new Error('`getEnv` is only available in react-server environment');
};
diff --git a/packages/waku/src/router/create-pages.ts b/packages/waku/src/router/create-pages.ts
index 10998b3d3..6c2ba82ba 100644
--- a/packages/waku/src/router/create-pages.ts
+++ b/packages/waku/src/router/create-pages.ts
@@ -773,8 +773,9 @@ export const new_createPages = <
return elementsCopy;
};
- const pageComponent = (staticComponentMap.get(joinPath(path, 'page')) ??
- dynamicPagePathMap.get(path)?.[1])!;
+ const pageComponent = (staticComponentMap.get(
+ joinPath(path, 'page').slice(1), // feels like a hack
+ ) ?? dynamicPagePathMap.get(path)?.[1])!;
const result: Record = {
root: createElement(
@@ -816,6 +817,8 @@ export const new_createPages = <
createNestedElements(routeChildren),
);
+ console.log(result);
+
return processSkip(result);
},
});
diff --git a/packages/waku/src/router/server.ts b/packages/waku/src/router/server.ts
index 559f506e7..a18ee6ddb 100644
--- a/packages/waku/src/router/server.ts
+++ b/packages/waku/src/router/server.ts
@@ -3,5 +3,5 @@ export {
unstable_rerenderRoute,
new_defineRouter,
} from './define-router.js';
-export { createPages } from './create-pages.js';
+export { createPages, new_createPages } from './create-pages.js';
export { fsRouter } from './fs-router.js';