vike-react 0.4.13 → 0.4.14

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/dist/+config.d.ts CHANGED
@@ -21,6 +21,7 @@ declare const _default: {
21
21
  server: true;
22
22
  client: true;
23
23
  };
24
+ cumulative: true;
24
25
  };
25
26
  title: {
26
27
  env: {
package/dist/+config.js CHANGED
@@ -24,7 +24,8 @@ export default {
24
24
  env: { server: true }
25
25
  },
26
26
  Layout: {
27
- env: { server: true, client: true }
27
+ env: { server: true, client: true },
28
+ cumulative: true
28
29
  },
29
30
  title: {
30
31
  env: { server: true, client: true }
@@ -2,11 +2,14 @@ export { getPageElement };
2
2
  import React from 'react';
3
3
  import { PageContextProvider } from '../hooks/usePageContext.js';
4
4
  function getPageElement(pageContext) {
5
- // Main component
6
- const Layout = pageContext.config.Layout ?? PassThrough;
7
5
  const { Page } = pageContext;
8
- let page = React.createElement(Layout, null, Page ? React.createElement(Page, null) : null);
9
- (pageContext.config.Wrapper || []).forEach((Wrapper) => {
6
+ let page = Page ? React.createElement(Page, null) : null;
7
+ [
8
+ // Inner wrapping
9
+ ...(pageContext.config.Layout || []),
10
+ // Outer wrapping
11
+ ...(pageContext.config.Wrapper || [])
12
+ ].forEach((Wrapper) => {
10
13
  page = React.createElement(Wrapper, null, page);
11
14
  });
12
15
  page = React.createElement(PageContextProvider, { pageContext: pageContext }, page);
@@ -15,6 +18,3 @@ function getPageElement(pageContext) {
15
18
  }
16
19
  return page;
17
20
  }
18
- function PassThrough({ children }) {
19
- return React.createElement(React.Fragment, null, children);
20
- }
@@ -9,13 +9,11 @@ declare global {
9
9
  /**
10
10
  * A component that defines the visual layout of the page common to several pages.
11
11
  *
12
- * Technically: the `<Layou>` component wraps the root component `<Page>`.
12
+ * Technically: the `<Layout>` component wraps the root component `<Page>`.
13
13
  *
14
14
  * https://vike.dev/Layout
15
15
  */
16
- Layout?: (props: {
17
- children: React.ReactNode;
18
- }) => React.ReactNode;
16
+ Layout?: Layout;
19
17
  /**
20
18
  * A component wrapping the the root component `<Page>`.
21
19
  *
@@ -81,10 +79,12 @@ declare global {
81
79
  }
82
80
  interface ConfigResolved {
83
81
  Wrapper?: Wrapper[];
82
+ Layout?: Layout[];
84
83
  }
85
84
  }
86
85
  }
87
86
  type Wrapper = (props: {
88
87
  children: React.ReactNode;
89
88
  }) => React.ReactNode;
89
+ type Layout = Wrapper;
90
90
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-react",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",