Skip to content

Commit

Permalink
docs: make "custom" the only demo framework
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Aug 14, 2023
1 parent acb7a96 commit 2ffb3ce
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Data } from "@measured/puck/types/Config";
import { Puck } from "@measured/puck/components/Puck";
import { Render } from "@measured/puck/components/Render";
import { Framework } from "../../Framework";
import { Framework } from "../Framework";
import { useEffect, useState } from "react";
import { Button } from "@measured/puck/components/Button";
import headingAnalyzer from "@measured/puck-plugin-heading-analyzer/src/HeadingAnalyzer";
Expand All @@ -19,8 +19,8 @@ export function Client({
isEdit: boolean;
framework: Framework;
}) {
const config = require(`../../configs/${framework}/`).default;
const initialData = require(`../../configs/${framework}/`).initialData || {};
const config = require(`../configs/${framework}/`).default;
const initialData = require(`../configs/${framework}/`).initialData || {};

const key = `puck-demo:${framework}:${path}`;

Expand Down Expand Up @@ -54,7 +54,7 @@ export function Client({
plugins={[headingAnalyzer]}
renderHeaderActions={() => (
<>
<Button href={`/${framework}/${path}`} newTab variant="secondary">
<Button href={path} newTab variant="secondary">
View page
</Button>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import dynamic from "next/dynamic";
import { notFound } from "next/navigation";
import resolvePuckPath from "./resolve-puck-path";
import { Metadata } from "next";
import { Framework, validFrameworks } from "../../Framework";

const Client = dynamic(() => import("./client"), {
ssr: false,
Expand Down Expand Up @@ -33,15 +31,5 @@ export default async function Page({
}) {
const { isEdit, path } = resolvePuckPath(params.puckPath);

if (validFrameworks.indexOf(params.framework) === -1) {
return notFound();
}

return (
<Client
isEdit={isEdit}
path={path}
framework={params.framework as Framework}
/>
);
return <Client isEdit={isEdit} path={path} framework={"custom"} />;
}
1 change: 0 additions & 1 deletion apps/demo/app/[framework]/page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions apps/demo/app/configs/custom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const initialData: Record<string, Data> = {
},
{
label: "Edit this page",
href: "/custom/edit",
href: "/edit",
variant: "secondary",
},
],
Expand Down Expand Up @@ -289,7 +289,7 @@ export const initialData: Record<string, Data> = {
},
{
label: "Edit this page",
href: "/custom/edit",
href: "/edit",
variant: "secondary",
},
],
Expand Down
13 changes: 5 additions & 8 deletions apps/demo/app/configs/custom/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export type RootProps = {
const NavItem = ({ label, href }: { label: string; href: string }) => {
const navPath = window.location.pathname.replace("/edit", "") || "/";

const isActive = navPath === href.replace("/edit", "");
const isActive = navPath === (href.replace("/edit", "") || "/");

return (
<a
href={href}
href={href || "/"}
style={{
textDecoration: "none",
color: isActive
Expand Down Expand Up @@ -54,15 +54,12 @@ function Root({ children, editMode }: RootProps) {
LOGO
</div>
<nav style={{ display: "flex", marginLeft: "auto", gap: 32 }}>
<NavItem label="Home" href={`/custom${editMode ? "/edit" : ""}`} />
<NavItem label="Home" href={`${editMode ? "/edit" : ""}`} />
<NavItem
label="Pricing"
href={`/custom/pricing${editMode ? "/edit" : ""}`}
/>
<NavItem
label="About"
href={`/custom/about${editMode ? "/edit" : ""}`}
href={`/pricing${editMode ? "/edit" : ""}`}
/>
<NavItem label="About" href={`/about${editMode ? "/edit" : ""}`} />
</nav>
</div>
</header>
Expand Down
21 changes: 2 additions & 19 deletions apps/demo/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
export default async function Page() {
return (
<div className="Page">
<h1 className="">Puck demo</h1>
<h2>Choose a demo framework</h2>
<div className="Frameworks">
<a className="Framework" href="/antd/edit">
Ant Design
</a>
<a className="Framework" href="/material-ui/edit">
Material UI
</a>
<a className="Framework" href="/custom/edit">
Custom example
</a>
</div>
</div>
);
}
export { default } from "./[...puckPath]/page";
export * from "./[...puckPath]/page";

0 comments on commit 2ffb3ce

Please sign in to comment.