Skip to content

Commit

Permalink
feat(next-drupal)!: add App Router support for Server Components
Browse files Browse the repository at this point in the history
Fixes #442

BREAKING CHANGE:

The useMenu() client hook has moved out of the main entry point and into its own
entry point. Any import or require of that function needs to be updated:

Old usage:
```js
import { useMenu } from "next-drupal"
```

New usage:
```js
import { useMenu } from "next-drupal/navigation"
```
  • Loading branch information
JohnAlbin committed Nov 20, 2023
1 parent 01a4d2e commit 564f59a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion packages/next-drupal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"description": "Helpers for Next.js + Drupal.",
"version": "1.6.0",
"sideEffects": false,
"source": "src/index.ts",
"source": [
"src/index.ts",
"src/navigation.ts"
],
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand All @@ -18,6 +21,16 @@
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./navigation": {
"import": {
"types": "./dist/navigation.d.ts",
"default": "./dist/navigation.js"
},
"require": {
"types": "./dist/navigation.d.cts",
"default": "./dist/navigation.cjs"
}
}
},
"license": "MIT",
Expand Down
1 change: 0 additions & 1 deletion packages/next-drupal/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from "./get-resource"
export * from "./get-search-index"
export * from "./get-view"
export * from "./types"
export * from "./use-menu"
export * from "./translate-path"
export {
deserialize,
Expand Down
1 change: 1 addition & 0 deletions packages/next-drupal/src/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useMenu } from "./navigation/use-menu"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
import { getMenu } from "./get-menu"
import type { DrupalMenuLinkContent } from "./types"
import { getMenu } from "../get-menu"
import type { DrupalMenuLinkContent } from "../types"

export function useMenu<T extends DrupalMenuLinkContent>(
name: string
Expand Down
2 changes: 1 addition & 1 deletion packages/next-drupal/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from "tsup"

export const tsup = defineConfig({
entry: ["src/index.ts"],
entry: ["src/index.ts", "src/navigation.ts"],
// Enable experimental code splitting support in CommonJS.
// splitting: true,
// Use Rollup for tree shaking.
Expand Down

0 comments on commit 564f59a

Please sign in to comment.