Skip to content

Commit 46eeb8c

Browse files
committed
docs: adjustments to configuration entry
1 parent e3d39cb commit 46eeb8c

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

www/content/docs/configuration.mdx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ NEXT_PUBLIC_DRUPAL_BASE_URL=http://example.com
2323

2424
### Pages Router
2525

26+
To create a new `NextDrupal` client, use the following initialization:
27+
28+
```ts
29+
import { NextDrupaPages } from "next-drupal"
30+
31+
const drupal = new NextDrupalPages(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL)
32+
```
33+
34+
Where `NEXT_PUBLIC_DRUPAL_BASE_URL` is the URL to your Drupal site defined as an [environment variable](/docs/environment-variables).
35+
36+
```txt title=.env.local
37+
NEXT_PUBLIC_DRUPAL_BASE_URL=http://example.com
38+
```
39+
2640
---
2741

2842
## Options
@@ -93,6 +107,24 @@ new NextDrupal(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, {
93107

94108
You can find more info about using a custom deserializer [here](/docs/deserializer).
95109

110+
#### Pages Router
111+
112+
This option is called `serializer` in the `NextDrupalPages` client. Aside from that, the usage is the same.
113+
114+
```ts
115+
import { Deserializer } from "jsonapi-serializer"
116+
117+
const jsonDeserializer = new Deserializer({
118+
keyForAttribute: "camelCase",
119+
})
120+
121+
const customDeserializer = jsonSerializer.deserialize.bind(jsonSerializer)
122+
123+
new NextDrupal(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, {
124+
serializer: customDeserializer,
125+
})
126+
```
127+
96128
---
97129

98130
### fetcher
@@ -228,7 +260,3 @@ JSON:API errors are thrown in non-production environments by default. The errors
228260
- **Required**: No
229261

230262
By default, the resource endpoint will be based on the resource name. If you turn this off, a JSON:API request will retrieve the resource's endpoint url.
231-
232-
---
233-
234-
TODO - Call out any App Router or Pages Router specific options here.

0 commit comments

Comments
 (0)