@okam/directus-next-component 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +14 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -4,19 +4,26 @@ This library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  ## directusRouteMiddleware usage
6
6
 
7
- Create a middleware.js file in your project and add the following code to it.
7
+ Create a middleware.ts file in the project, in the `/src/app` directory of the next application, and add the following code to it.
8
8
 
9
9
  ```jsx
10
- // middleware.js
10
+ // middleware.ts
11
11
 
12
- import {directusRouteMiddleware, directusRouteMiddlewareConfig} from @okam/directus-next-component
12
+ import {
13
+ directusRouteMiddleware,
14
+ config as directusRouteMiddlewareConfig,
15
+ } from '@okam/directus-next-component/src/server'
16
+ import type { NextRequest } from 'next/server'
13
17
 
14
- export function middleware(request) {
15
- return directusRouteMiddleware(request);
18
+ export function middleware(request: NextRequest) {
19
+ const { locale } = request.nextUrl
20
+ return directusRouteMiddleware(request, [locale])
16
21
  }
17
22
 
18
- export config = {
19
- ...directusRouteMiddlewareConfig
23
+ export const config = {
24
+ ...directusRouteMiddlewareConfig,
20
25
  }
26
+
21
27
  ```
22
28
 
29
+ After, modify the `next.config.js` file to add `withDirectus` in the plugins.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@okam/directus-next-component",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "module": "./index.esm.js",
5
5
  "type": "module",
6
6
  "main": "./index.esm.js"
7
- }
7
+ }