Skip to content

Commit

Permalink
docs: adjustments to configuration entry
Browse files Browse the repository at this point in the history
  • Loading branch information
backlineint committed Nov 8, 2024
1 parent e3d39cb commit 46eeb8c
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions www/content/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ NEXT_PUBLIC_DRUPAL_BASE_URL=http://example.com

### Pages Router

To create a new `NextDrupal` client, use the following initialization:

```ts
import { NextDrupaPages } from "next-drupal"

const drupal = new NextDrupalPages(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL)
```

Where `NEXT_PUBLIC_DRUPAL_BASE_URL` is the URL to your Drupal site defined as an [environment variable](/docs/environment-variables).

```txt title=.env.local
NEXT_PUBLIC_DRUPAL_BASE_URL=http://example.com
```

---

## Options
Expand Down Expand Up @@ -93,6 +107,24 @@ new NextDrupal(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, {

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

#### Pages Router

This option is called `serializer` in the `NextDrupalPages` client. Aside from that, the usage is the same.

```ts
import { Deserializer } from "jsonapi-serializer"

const jsonDeserializer = new Deserializer({
keyForAttribute: "camelCase",
})

const customDeserializer = jsonSerializer.deserialize.bind(jsonSerializer)

new NextDrupal(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, {
serializer: customDeserializer,
})
```

---

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

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.

---

TODO - Call out any App Router or Pages Router specific options here.

0 comments on commit 46eeb8c

Please sign in to comment.