Skip to content

Commit

Permalink
support for next@15
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbenegas committed Oct 21, 2024
1 parent 48b3a65 commit 3219480
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions packages/basehub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# basehub

## 7.5.14

### Patch Changes

- Support next@15

## 7.5.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/basehub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "basehub",
"description": "A very fast Headless CMS.",
"author": "JB <[email protected]>",
"version": "7.5.13",
"version": "7.5.14",
"license": "MIT",
"repository": "basehub-ai/basehub",
"bugs": "https://github.com/basehub-ai/basehub/issues",
Expand Down
22 changes: 13 additions & 9 deletions packages/basehub/src/next/toolbar/server-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const LazyClientConditionalRenderer = React.lazy(() =>

type ServerToolbarProps = Parameters<typeof basehub>[0];

export const ServerToolbar = ({ ...basehubProps }: ServerToolbarProps) => {
export const ServerToolbar = async ({
...basehubProps
}: ServerToolbarProps) => {
const { isForcedDraft } = getStuffFromEnv(basehubProps);

const enableDraftMode = async ({
Expand Down Expand Up @@ -50,7 +52,7 @@ export const ServerToolbar = ({ ...basehubProps }: ServerToolbarProps) => {
return { status: 400, response: { error: "Bad request" } };
}
const response = await res.json();
if (res.status === 200) draftMode().enable();
if (res.status === 200) (await draftMode()).enable();
return { status: res.status, response };
} catch (error) {
return { status: 500, response: { error: "Something went wrong" } };
Expand Down Expand Up @@ -93,22 +95,24 @@ export const ServerToolbar = ({ ...basehubProps }: ServerToolbarProps) => {

const disableDraftMode = async () => {
"use server";
draftMode().disable();
(await draftMode()).disable();
};

const revalidateTags = async ({ tags }: { tags: string[] }) => {
"use server";
tags.forEach((tag) => {
if (tag.startsWith("basehub-")) {
revalidateTag(tag);
}
});
await Promise.all(
tags.map(async (tag) => {
if (tag.startsWith("basehub-")) {
await revalidateTag(tag);
}
})
);
return { success: true };
};

return (
<LazyClientConditionalRenderer
draft={draftMode().isEnabled}
draft={(await draftMode()).isEnabled}
isForcedDraft={isForcedDraft}
enableDraftMode={enableDraftMode}
disableDraftMode={disableDraftMode}
Expand Down
7 changes: 7 additions & 0 deletions playground/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# playground

## 0.0.156

### Patch Changes

- Updated dependencies
- [email protected]

## 0.0.155

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "playground",
"private": true,
"version": "0.0.155",
"version": "0.0.156",
"scripts": {
"dev": "basehub dev & next dev --port 3003",
"build": "basehub && next build",
Expand Down

0 comments on commit 3219480

Please sign in to comment.