From 32b5e211886112fd82f894a0d66df3714ec9ea25 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sun, 22 Oct 2023 23:08:56 +0800 Subject: [PATCH] feat(next-drupal)!: add App Router support for Server Components 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" ``` --- packages/next-drupal/package.json | 15 ++++++++++++++- packages/next-drupal/src/index.ts | 1 - packages/next-drupal/src/navigation.ts | 1 + .../next-drupal/src/{ => navigation}/use-menu.tsx | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 packages/next-drupal/src/navigation.ts rename packages/next-drupal/src/{ => navigation}/use-menu.tsx (90%) diff --git a/packages/next-drupal/package.json b/packages/next-drupal/package.json index a4baf853..d22717ef 100644 --- a/packages/next-drupal/package.json +++ b/packages/next-drupal/package.json @@ -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.modern.js", @@ -17,6 +20,16 @@ "types": "./dist/index.cjs.d.ts", "default": "./dist/index.cjs" } + }, + "./navigation": { + "import": { + "types": "./dist/navigation.d.ts", + "default": "./dist/navigation.modern.js" + }, + "require": { + "types": "./dist/navigation.cjs.d.ts", + "default": "./dist/navigation.cjs" + } } }, "types": "dist/types.d.ts", diff --git a/packages/next-drupal/src/index.ts b/packages/next-drupal/src/index.ts index bc107a47..fb7c2513 100644 --- a/packages/next-drupal/src/index.ts +++ b/packages/next-drupal/src/index.ts @@ -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, diff --git a/packages/next-drupal/src/navigation.ts b/packages/next-drupal/src/navigation.ts new file mode 100644 index 00000000..33d5f232 --- /dev/null +++ b/packages/next-drupal/src/navigation.ts @@ -0,0 +1 @@ +export { useMenu } from "./navigation/use-menu" diff --git a/packages/next-drupal/src/use-menu.tsx b/packages/next-drupal/src/navigation/use-menu.tsx similarity index 90% rename from packages/next-drupal/src/use-menu.tsx rename to packages/next-drupal/src/navigation/use-menu.tsx index 441a2a43..cbc4b3f6 100644 --- a/packages/next-drupal/src/use-menu.tsx +++ b/packages/next-drupal/src/navigation/use-menu.tsx @@ -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( name: string