Skip to content

Commit 239b578

Browse files
author
Marco Monti
committed
docs(next-drupal): requested changes
1 parent 6c0e389 commit 239b578

31 files changed

+540
-146
lines changed

www/config/docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const docsConfig: DocsConfig = {
162162
},
163163
{
164164
title: "buildEndpoint",
165-
href: "/docs/reference/buildEndpoint",
165+
href: "/docs/reference/buildendpoint",
166166
},
167167
{
168168
title: "getAccessToken",

www/content/docs/authentication.mdx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ const articles = await drupal.getResourceCollection("node--article", {
177177

178178
If you're using [NextAuth](https://next-auth.js.org) you can use the results from `getSession`:
179179

180-
<!--
181-
************************************************************
182-
* TODO: Remove this block before publishing.
183-
184-
* Comment: Need to corroborate this with NextAuth updates
185-
************************************************************
186-
-->
187-
188180
```ts
189181
import { getSession } from "next-auth/react"
190182

www/content/docs/cache.mdx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@ title: Caching
33
excerpt: Using a custom cache for resources.
44
---
55

6-
The `NextDrupal` has support for caching resources.
6+
The `NextDrupal` client has support for caching resources.
77

88
This is handy when dealing with global data: you can fetch data once and re-use during builds.
99

1010
You can provide your own cache implementation using the [`cache`](/docs/configuration#cache) option.
1111

1212
---
1313

14-
<!--
15-
************************************************************
16-
* TODO: Remove this block before publishing.
17-
18-
* Comment: Not sure how this cache option works with Next.js caching system
19-
************************************************************
20-
-->
21-
2214
## Example
2315

2416
Here's an example on how you can use Redis to cache resources.

www/content/docs/client.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: NextDrupal Client
33
excerpt: A powerful JSON:API client for Drupal.
44
---
55

6-
The `NextDrupal` is a powerful JSON:API client that ships with helpers for working with Drupal data.
6+
The `NextDrupal` client is a powerful JSON:API client that ships with helpers for working with Drupal data.
77

8-
You can use the `NextDrupal` client to fetch JSON:API data from Drupal to build static pages.
8+
You can use the `NextDrupal` client to fetch JSON:API data from Drupal to build static pages in advance, or server render pages on-demand.
99

1010
It also comes with full support for JSON:API write operations which means you can create JSON:API resources from Next.js to Drupal.
1111

www/content/docs/configuration.mdx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ excerpt: Initialization and options for NextDrupal client.
55

66
## Initialization
77

8-
To create a new `NextDrupal`, use the following initialization:
8+
To create a new `NextDrupal` client, use the following initialization:
99

1010
```ts
1111
import { NextDrupal } from "next-drupal"
@@ -125,14 +125,6 @@ You can find more info about using a custom fetcher [here](/docs/fetcher).
125125

126126
### cache
127127

128-
<!--
129-
************************************************************
130-
* TODO: Remove this block before publishing.
131-
132-
* Comment: Not Sure how this works with NextJS cache system
133-
************************************************************
134-
-->
135-
136128
- **Default value**: `null`
137129
- **Required**: No
138130

@@ -181,14 +173,6 @@ Set whether the client should use authenticated requests by default. If set to `
181173

182174
---
183175

184-
<!--
185-
************************************************************
186-
* TODO: Remove this block before publishing.
187-
188-
* Comment: I believe this option is no longer available on the new NextDrupal options
189-
************************************************************
190-
-->
191-
192176
### headers
193177

194178
- **Default value**: `{ "Content-Type": "application/vnd.api+json", Accept: "application/vnd.api+json" }`

www/content/docs/creating-resources.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ If you're working with JSON:API, be mindful to select the option:
1515

1616
`Accept all JSON:API create, read, update, and delete operations.`
1717

18-
on the following path: `/admin/config/services/jsonapi` on Drupal.
18+
on the following path: `/admin/config/services/jsonapi` in Drupal.
1919

2020
</Callout>
2121

22-
The `NextDrupal` client ships with a `createResource` and a `createFileResource` methods for creating JSON:API resources.
22+
The `NextDrupal` client ships with `createResource` and `createFileResource` methods for creating JSON:API resources.
2323

2424
---
2525

www/content/docs/deleting-resources.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you're working with JSON:API, be mindful to select the option:
1515

1616
`Accept all JSON:API create, read, update, and delete operations.`
1717

18-
on the following path: `/admin/config/services/jsonapi` on Drupal.
18+
on the following path: `/admin/config/services/jsonapi` in Drupal.
1919

2020
</Callout>
2121

www/content/docs/fetcher.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ excerpt: Using a custom fetcher with NextDrupal.
77
************************************************************
88
* TODO: Remove this block before publishing.
99

10-
* Comment: Not sure how a custom fetcher will work because of the caching options of the Nextjs extended fetch API
10+
* Comment: In order to support a custom fetcher and handle caching withouth the native polyfilled fetch, 'unstable_cache' from next should be used, but also the NextDrupal client should support passing revalidate options.
1111
************************************************************
1212
-->
1313

www/content/docs/fetching-resources.mdx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,3 @@ const article = await drupal.getResourceCollection(
168168
// highlight-end
169169
)
170170
```
171-
172-
<!--
173-
/// This link is broken: Remove it or create page with examples ?
174-
## More
175-
176-
See the [Examples](/examples) section for data fetching examples.
177-
-->

www/content/docs/pages.mdx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ title: Building Pages
33
excerpt: How to build pages using JSON:API resources from Drupal.
44
---
55

6-
In Next.js V14, data fetching has evolved significantly from previous versions. Instead of using `getStaticProps` and `getServerSideProps` you now use the native `fetch` function enhanced by Next.js to handle server-side data fetching. This allows you to configure caching and revalidation directly within your fetch requests. These can be used in Server Components, Route Handlers, and Server Actions. You can read more about it [here](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating)
6+
In Next.js V14, data fetching has evolved significantly from previous versions. Instead of using `getStaticProps` and `getServerSideProps` you now use the native `fetch` function enhanced by Next.js to handle server-side data fetching.
77

8-
The `NextDrupal` client provides several functions to help you query JSON:API resources from Drupal and manage these revalidation options on the `fetch` request level.
8+
The `NextDrupal` client provides several functions to help you query JSON:API resources from Drupal.
99

1010
<!--
1111
************************************************************
1212
* TODO: Remove this block before publishing.
1313

14-
* Comment: Need to corroborate (and maybe update) once next-drupal supports `next` revalidation options
14+
* Comment: Need to corroborate (and maybe update) once next-drupal supports `next` revalidation options. Possible replacement for above introduction once it's supported
15+
16+
In Next.js V14, data fetching has evolved significantly from previous versions. Instead of using `getStaticProps` and `getServerSideProps` you now use the native `fetch` function enhanced by Next.js to handle server-side data fetching. This allows you to configure caching and revalidation directly within your fetch requests. These can be used in Server Components, Route Handlers, and Server Actions. You can read more about it [here](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating)
17+
18+
The `NextDrupal` client provides several functions to help you query JSON:API resources from Drupal and manage these revalidation options on the `fetch` request level.
19+
1520
************************************************************
1621
-->
1722

@@ -52,7 +57,7 @@ export default function AboutPage() {
5257

5358
## Dynamic pages
5459

55-
You can use Next.js [dynamic route](https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes) to build static pages for Drupal entity types.
60+
You can use Next.js [dynamic routes](https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes) to build static pages for Drupal entity types.
5661

5762
Start by creating a page at `/app/[...slug]/page.tsx`, where `[...slug]` maps to the **path alias** for an entity type (or content type) in Drupal.
5863

@@ -134,17 +139,17 @@ export default function Page({ params }) {
134139
params.addFields("node--article", ["title", "path", "body", "uid"])
135140
}
136141

137-
const node = await drupal.getResourceByPath(path, {
142+
const node = await drupal.getResource(path, path.entity.uuid {
138143
params: params.getQueryObject(),
139144
})
140145

141-
// Render different Components based on Node type
146+
// Render different Components based on Node type.
142147
if (node.type === "node--page") {
143-
return <PageComponent />
148+
return <PageComponent node={node}/>
144149
}
145150

146151
if (node.type === "node--article") {
147-
return <ArticleComponent />
152+
return <ArticleComponent node={node}/>
148153
}
149154

150155
return null

0 commit comments

Comments
 (0)