@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.
- package/README.md +14 -7
- 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.
|
|
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.
|
|
10
|
+
// middleware.ts
|
|
11
11
|
|
|
12
|
-
import
|
|
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
|
-
|
|
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.
|