Skip to content

Commit

Permalink
pages pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Mar 20, 2024
1 parent 66cae54 commit 7e458ec
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions components/Pages/Home/Client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client"
import React from "react"
import { Renderer } from "./Renderer"
import { HomeProps } from "./types"
import { useTina } from "tinacms/dist/react"

export const HomeClient: React.FC<HomeProps> = ({ pageInfo }) => {
const z = useTina({
// @ts-ignore
query: pageInfo.query,
// @ts-ignore
variables: pageInfo.variables,
data: pageInfo.data
})

return (
<Renderer pageInfo={z} />
)
}
9 changes: 9 additions & 0 deletions components/Pages/Home/Renderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { HomeProps } from "./types";

export const Renderer: React.FC<HomeProps> = ({ pageInfo }) => {
return (
<div>
{JSON.stringify(pageInfo.data, null, 2)}
</div>
)
}
6 changes: 6 additions & 0 deletions components/Pages/Home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { HomeClient } from "./Client";
import { Renderer } from "./Renderer";

const Home = process.env.NODE_ENV === "development" ? HomeClient : Renderer;

export default Home;
5 changes: 5 additions & 0 deletions components/Pages/Home/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type HomeProps = {
pageInfo: {
data: any
}
}

0 comments on commit 7e458ec

Please sign in to comment.