-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(next-drupal): requested changes
- Loading branch information
Marco Monti
committed
Sep 9, 2024
1 parent
6c0e389
commit 239b578
Showing
31 changed files
with
540 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: getEntryForResourceType | ||
excerpt: Get the JSON:API entry for a resource type. | ||
--- | ||
|
||
```ts | ||
const url = await drupal.getEntryForResourceType(type, locale?): Promise<string> | ||
``` | ||
- `type: string` | ||
- **Required** | ||
- The resource type. Example: `node--article`. | ||
- `locale: string` | ||
- Optional | ||
- The locale to fetch the index. Example: `es` or `fr`. | ||
--- | ||
## Notes | ||
By default, when retrieving resources in `getResource` or `getResourceCollection`, the `NextDrupalPages` make a request to Drupal to fetch the JSON:API resource entry.. | ||
Example: if you provide `node--article`, `NextDrupalPages` will make a request to `http://example.com/jsonapi/node/article`. | ||
|
||
If you would like to infer the entry from the resource type, use the [`useDefaultResourceTypeEntry`](/docs/configuration#usedefaultresourcetypeentry) option. | ||
|
||
```ts | ||
const drupal = new NextDrupalPages(process.env.NEXT_PUBLIC_DRUPAL_BASE_URL, { | ||
useDefaultResourceTypeEntry: true, | ||
}) | ||
``` | ||
|
||
--- | ||
|
||
## Examples | ||
|
||
```ts | ||
// https://example.com/jsonapi/node/article. | ||
const url = await drupal.getEntryForResourceType(`node--article`) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: getPathFromContext | ||
excerpt: Return the path (slug) from getStaticProps or getServerSideProps context. | ||
--- | ||
|
||
```ts | ||
const slug = drupal.getPathFromContext( | ||
context, | ||
options?: { | ||
pathPrefix, | ||
} | ||
): string | ||
``` | ||
|
||
- `context: GetStaticPropsContext | GetServerSidePropsContext` | ||
- **Required** | ||
- The context from `getStaticProps` or `getServerSideProps`. | ||
- `options` | ||
- Optional | ||
- `pathPrefix: string`: Set the pathPrefix if you're calling from a subdir. Example: for `/articles/[...slug].tsx`, use `pathPrefix: "/articles"`. | ||
|
||
--- | ||
|
||
## Examples | ||
|
||
- Get the path (slug) from `getStaticProps` context. | ||
|
||
```ts | ||
export async function getStaticProps(context) { | ||
const slug = await drupal.getPathFromContext(context) | ||
} | ||
``` |
Oops, something went wrong.