Skip to content

Commit

Permalink
feat: add headerTitle and headerPath APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Aug 14, 2023
1 parent 2ffb3ce commit ae5c7c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/demo/app/[...puckPath]/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function Client({
localStorage.setItem(key, JSON.stringify(data));
}}
plugins={[headingAnalyzer]}
headerPath={path}
renderHeaderActions={() => (
<>
<Button href={path} newTab variant="secondary">
Expand Down
11 changes: 10 additions & 1 deletion packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export function Puck({
plugins = [],
renderHeader,
renderHeaderActions,
headerTitle,
headerPath,
}: {
config: Config;
data: Data;
Expand All @@ -75,6 +77,8 @@ export function Puck({
data: Data;
setData: (data: Data) => void;
}) => ReactElement;
headerTitle?: string;
headerPath?: string;
}) {
const [data, setData] = useState(initialData);
const [selectedIndex, setSelectedIndex] = useState<number | null>(null);
Expand Down Expand Up @@ -256,7 +260,12 @@ export function Puck({
}}
>
<Heading rank={2} size="xs">
{data.root.title || "Page"}
{headerTitle || data.root.title || "Page"}
{headerPath && (
<small style={{ fontWeight: 400, marginLeft: 4 }}>
<code>{headerPath}</code>
</small>
)}
</Heading>
</div>
<div
Expand Down

0 comments on commit ae5c7c2

Please sign in to comment.