Skip to content

Commit

Permalink
chore: small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magne4000 committed Sep 25, 2023
1 parent ce54bec commit 29ffdbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
6 changes: 3 additions & 3 deletions vike-solid/renderer/+config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { Config, ConfigEffect, PageContext } from "vite-plugin-ssr/types";
// We purposely define the ConfigVikeSolid interface in this file: that way we ensure it's always applied whenever the user `import vikeSolid from 'vike-solid'`
import type { Component } from "./types.js";

// Depending on the value of `config.meta.ssr`, set other config options' `env`
// accordingly.
Expand Down Expand Up @@ -54,11 +56,9 @@ export default {
},
} satisfies Config;

// We purposely define the ConfigVikeSolid interface in this file: that way we ensure it's always applied whenever the user `import vikeSolid from 'vike-solid'`
import type { Component } from "./types.js";
declare global {
namespace VikePackages {
interface ConfigVikeReact {
interface ConfigVikeSolid {
/** Solid element renderer and appended into <head></head> */
Head?: Component;
Layout?: Component;
Expand Down
21 changes: 4 additions & 17 deletions vike-solid/renderer/getPageElement.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
export { getPageElement };

import type { PageContext } from "vite-plugin-ssr/types";
import { PageContextProvider, usePageContext } from "./PageContextProvider";
import type { JSX } from "solid-js";
import { Dynamic } from "solid-js/web";
import type { Store } from "solid-js/store";

function getPageElement(pageContext: Store<PageContext>): JSX.Element {
export function getPageElement(pageContext: Store<PageContext>): JSX.Element {
const page = (
<PageContextProvider pageContext={pageContext}>
<Wrapper>
<Layout>
<Page />
</Layout>
</Wrapper>
<Layout>
<Page />
</Layout>
</PageContextProvider>
);
return page;
}

function Wrapper(props: { children: JSX.Element }) {
const pageContext = usePageContext();
return (
<Dynamic component={/*pageContext.config.Wrapper ??*/ Passthrough}>
{props.children}
</Dynamic>
);
}

function Layout(props: { children: JSX.Element }) {
const pageContext = usePageContext();
return (
Expand Down

0 comments on commit 29ffdbe

Please sign in to comment.