diff --git a/src/pages/+Page.ts b/src/pages/+Page.ts new file mode 100644 index 00000000..74be692e --- /dev/null +++ b/src/pages/+Page.ts @@ -0,0 +1,13 @@ +import h from "@macrostrat/hyper"; +import { Link } from "~/renderer/Link"; + +export function Page() { + return h([ + h("h1", "Macrostrat dev"), + h("ul", [ + h("li", h(Link, { href: "map" }, "Map")), + h("li", h(Link, { href: "maps" }, "Map index")), + h("li", h(Link, { href: "dev" }, "Dev layers")), + ]), + ]); +} diff --git a/src/pages/+Page.tsx b/src/pages/+Page.tsx deleted file mode 100644 index 01337b3b..00000000 --- a/src/pages/+Page.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Link } from "~/renderer/Link"; - -export function Page() { - return ( - <> -

Macrostrat dev

- - - ); -} diff --git a/src/pages/_error/+Page.ts b/src/pages/_error/+Page.ts new file mode 100644 index 00000000..91457e2d --- /dev/null +++ b/src/pages/_error/+Page.ts @@ -0,0 +1,14 @@ +export { Page }; + +import h from "@macrostrat/hyper"; + +function Page({ is404 }: { is404: boolean }) { + if (is404) { + return h([ + h("h1", "404 Page Not Found"), + h("p", "This page could not be found."), + ]); + } else { + return h([h("h1", "500 Internal Error"), h("p", "Something went wrong.")]); + } +} diff --git a/src/pages/_error/+Page.tsx b/src/pages/_error/+Page.tsx deleted file mode 100644 index 92ceb508..00000000 --- a/src/pages/_error/+Page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -export { Page } - -function Page({ is404 }: { is404: boolean }) { - if (is404) { - return ( - <> -

404 Page Not Found

-

This page could not be found.

- - ) - } else { - return ( - <> -

500 Internal Error

-

Something went wrong.

- - ) - } -} diff --git a/src/pages/about/+Page.tsx b/src/pages/about/+Page.tsx deleted file mode 100644 index 3120478e..00000000 --- a/src/pages/about/+Page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import "./code.css"; - -export { Page }; - -function Page() { - return ( - <> -

About

-

- Example of using vike. -

- - ); -} diff --git a/src/pages/about/code.css b/src/pages/about/code.css deleted file mode 100644 index 1e5a0221..00000000 --- a/src/pages/about/code.css +++ /dev/null @@ -1,6 +0,0 @@ -code { - font-family: monospace; - background-color: #eaeaea; - padding: 3px 5px; - border-radius: 4px; -} diff --git a/src/renderer/+onRenderClient.tsx b/src/renderer/+onRenderClient.ts similarity index 88% rename from src/renderer/+onRenderClient.tsx rename to src/renderer/+onRenderClient.ts index d1019168..84393d7d 100644 --- a/src/renderer/+onRenderClient.tsx +++ b/src/renderer/+onRenderClient.ts @@ -1,6 +1,7 @@ export { render as onRenderClient }; import { FocusStyleManager } from "@blueprintjs/core"; +import h from "@macrostrat/hyper"; import { hydrateRoot } from "react-dom/client"; import { PageShell } from "./page-shell"; import type { PageContextClient } from "./types"; @@ -18,12 +19,7 @@ async function render(pageContext: PageContextClient) { console.log("Rendering on client"); const root = document.getElementById("app-container"); if (!root) throw new Error("DOM element #react-root not found"); - hydrateRoot( - root, - - - - ); + hydrateRoot(root, h(PageShell, { pageContext }, h(Page, pageProps))); } /* To enable Client-side Routing: diff --git a/src/renderer/+onRenderHtml.tsx b/src/renderer/+onRenderHtml.ts similarity index 95% rename from src/renderer/+onRenderHtml.tsx rename to src/renderer/+onRenderHtml.ts index e00cec93..4f549629 100644 --- a/src/renderer/+onRenderHtml.tsx +++ b/src/renderer/+onRenderHtml.ts @@ -1,6 +1,7 @@ export { render as onRenderHtml }; // See https://vike.dev/data-fetching +import h from "@macrostrat/hyper"; import ReactDOMServer from "react-dom/server"; import { dangerouslySkipEscape, escapeInject } from "vike/server"; import { PageShell } from "./page-shell"; @@ -12,9 +13,7 @@ async function render(pageContext: PageContextServer) { if (!Page) throw new Error("render() hook expects pageContext.Page to be defined"); const pageHtml = ReactDOMServer.renderToString( - - - + h(PageShell, { pageContext }, h(Page, pageProps)) ); // See https://vike.dev/head diff --git a/src/renderer/Link.tsx b/src/renderer/Link.ts similarity index 81% rename from src/renderer/Link.tsx rename to src/renderer/Link.ts index a84e86bc..3c40b5a8 100644 --- a/src/renderer/Link.tsx +++ b/src/renderer/Link.ts @@ -1,3 +1,4 @@ +import h from "@macrostrat/hyper"; import { usePageContext } from "./page-context"; export function Link(props: { @@ -12,5 +13,5 @@ export function Link(props: { ] .filter(Boolean) .join(" "); - return ; + return h("a", { ...props, className }); }