From 925e6b7d02f83e162791f83f01e0c8b4f705614e Mon Sep 17 00:00:00 2001 From: Bon Nicolai Mercado Date: Fri, 18 Oct 2024 07:04:28 +0800 Subject: [PATCH] feat: use strapi --- apps/website/package.json | 66 ++-- apps/website/src/app/clientLayout.tsx | 426 +++++++++++++----------- apps/website/src/app/hooks/UseStrapi.ts | 48 +++ apps/website/src/app/page.tsx | 190 ++++++----- 4 files changed, 422 insertions(+), 308 deletions(-) create mode 100644 apps/website/src/app/hooks/UseStrapi.ts diff --git a/apps/website/package.json b/apps/website/package.json index 9f78a03..921f664 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -1,35 +1,35 @@ { - "name": "website", - "version": "0.1.0", - "private": true, - "scripts": { - "dev": "doppler run --preserve-env -- next dev", - "build": "next build", - "start": "next start", - "lint": "next lint", - "test": "vitest", - "preview": "pnpm dlx http-server out" - }, - "dependencies": { - "@frontline-hq/untitledui-icons": "^0.0.4", - "@lilypad/shared-components": "workspace:~", - "@react-spring/web": "^9.7.4", - "next": "14.2.4", - "react": "^18", - "react-dom": "^18", - "react-intersection-observer": "^9.13.0", - "tailwind-merge": "^2.3.0" - }, - "devDependencies": { - "@lilypad/uui-tailwind-styles": "workspace:~", - "@types/node": "^20", - "@types/react": "^18", - "@types/react-dom": "^18", - "autoprefixer": "^10.4.19", - "eslint": "^8", - "eslint-config-next": "14.2.4", - "postcss": "^8.4.38", - "tailwindcss": "^3.4.3", - "typescript": "^5" - } + "name": "website", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "doppler run --preserve-env -- next dev", + "build": "doppler run --preserve-env -- next build", + "start": "next start", + "lint": "next lint", + "test": "vitest", + "preview": "pnpm dlx http-server out" + }, + "dependencies": { + "@frontline-hq/untitledui-icons": "^0.0.4", + "@lilypad/shared-components": "workspace:~", + "@react-spring/web": "^9.7.4", + "next": "14.2.4", + "react": "^18", + "react-dom": "^18", + "react-intersection-observer": "^9.13.0", + "tailwind-merge": "^2.3.0" + }, + "devDependencies": { + "@lilypad/uui-tailwind-styles": "workspace:~", + "@types/node": "^20", + "@types/react": "^18", + "@types/react-dom": "^18", + "autoprefixer": "^10.4.19", + "eslint": "^8", + "eslint-config-next": "14.2.4", + "postcss": "^8.4.38", + "tailwindcss": "^3.4.3", + "typescript": "^5" + } } diff --git a/apps/website/src/app/clientLayout.tsx b/apps/website/src/app/clientLayout.tsx index a97c48f..5cb7d79 100644 --- a/apps/website/src/app/clientLayout.tsx +++ b/apps/website/src/app/clientLayout.tsx @@ -6,7 +6,7 @@ import _NavItemBase from "@/components/_NavItemBase/_NavItemBase"; import _ApplicationNavMenuButton from "@/components/_ApplicationNavMenuButton/_ApplicationNavMenuButton"; import NavBar from "@/components/NavBar"; import Image from "next/image"; -import { useState } from "react"; +import { Context, useState } from "react"; import { usePathname } from "next/navigation"; import _NavItemDropdown from "@/components/_NavItemDropdown/_NavItemDropdown"; import _NavMenuItem from "@/components/_NavMenuItem/_NavMenuItem"; @@ -24,9 +24,17 @@ import { import { Anchor } from "@lilypad/shared-components"; import Footer from "@/components/Footer"; import { animated, useSpring } from "@react-spring/web"; +import { createContext } from "react"; +import useStrapi, { StrapiContext } from "./hooks/UseStrapi"; const INTER = Inter({ subsets: ["latin"] }); +export const PageContext: Context = createContext({ + strapi: { + mission_statement: "", + }, +}); + export default function ClientLayout({ children, }: Readonly<{ @@ -36,8 +44,8 @@ export default function ClientLayout({ const [nestedMenu, setNestedMenu] = useState( null ); - const pathname = usePathname(); + const { strapi, isLoading: isCmsLoading } = useStrapi({ pathname }); const resourcesArray = [ { @@ -151,149 +159,134 @@ export default function ClientLayout({ to: { opacity: 1 }, config: { duration: 1 }, }); - return ( - - - {"alt"} - - } - menuButton={ - <_ApplicationNavMenuButton> - } - openedState={{ - opened: menuOpened, - setOpened: setMenuOpened, - }} - trailingCTA={ - + + + {"alt"} + + } + menuButton={ + <_ApplicationNavMenuButton> + } + openedState={{ + opened: menuOpened, + setOpened: setMenuOpened, }} + trailingCTA={ + + Get Started + + } > - Get Started - - } - > - {nestedMenu != null && menuOpened ? ( - - ) : null} - {menuOpened ? ( - <> - {nestedMenu === null && ( - <> - - { - setMenuOpened(() => false); - }} - > - <_NavItemBase - current={pathname === "/"} - > - {"Products"} - - - - - { - setMenuOpened(() => false); - }} - > - <_NavItemBase - current={pathname === "/docs"} - > - {"Docs"} - - - - )} - {nestedMenu === "About" ? ( -
- {aboutArray.map((item, index) => ( - <_NavMenuItem - key={index} - description={item.description} - title={item.title} - iconUrl={item.iconUrl} - href={item.href} - /> - ))} -
- ) : nestedMenu === "Resources" ? ( -
- {resourcesArray.map((item, index) => ( - <_NavMenuItem - key={index} - description={item.description} - title={item.title} - iconUrl={item.iconUrl} - href={item.href} - /> - ))} -
+ {nestedMenu != null && menuOpened ? ( + ) : null} - - ) : ( - <> - <_NavItemDropdown - current={pathname === "/About"} - > - {{ - title: "About", - dropdownList: ( + {menuOpened ? ( + <> + {nestedMenu === null && ( <> + + { + setMenuOpened( + () => false + ); + }} + > + <_NavItemBase + current={ + pathname === "/" + } + > + {"Products"} + + + + + { + setMenuOpened( + () => false + ); + }} + > + <_NavItemBase + current={ + pathname === "/docs" + } + > + {"Docs"} + + + + )} + {nestedMenu === "About" ? ( +
{aboutArray.map( (item, index) => ( <_NavMenuItem @@ -309,27 +302,9 @@ export default function ClientLayout({ /> ) )} - - ), - }} - - { - setMenuOpened(() => false); - }} - > - <_NavItemBase current={pathname === "/"}> - {"Products"} - - - <_NavItemDropdown - current={pathname === "/Resources"} - > - {{ - title: "Resources", - dropdownList: ( - <> +
+ ) : nestedMenu === "Resources" ? ( +
{resourcesArray.map( (item, index) => ( <_NavMenuItem @@ -345,36 +320,111 @@ export default function ClientLayout({ /> ) )} - - ), - }} - +
+ ) : null} + + ) : ( + <> + <_NavItemDropdown + current={pathname === "/About"} + > + {{ + title: "About", + dropdownList: ( + <> + {aboutArray.map( + (item, index) => ( + <_NavMenuItem + key={index} + description={ + item.description + } + title={ + item.title + } + iconUrl={ + item.iconUrl + } + href={ + item.href + } + /> + ) + )} + + ), + }} + + { + setMenuOpened(() => false); + }} + > + <_NavItemBase + current={pathname === "/"} + > + {"Products"} + + + <_NavItemDropdown + current={pathname === "/Resources"} + > + {{ + title: "Resources", + dropdownList: ( + <> + {resourcesArray.map( + (item, index) => ( + <_NavMenuItem + key={index} + description={ + item.description + } + title={ + item.title + } + iconUrl={ + item.iconUrl + } + href={ + item.href + } + /> + ) + )} + + ), + }} + - { - setMenuOpened(() => false); - }} - > - <_NavItemBase - current={pathname === "/docs"} - > - {"Docs"} - - - - )} -
-
- {children} -