Skip to content

Commit 1509e09

Browse files
committed
docs: add remaining examples to getResourceFromContext typedoc
1 parent 27cd1b7 commit 1509e09

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/next-drupal/src/next-drupal-pages.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,32 @@ export class NextDrupalPages extends NextDrupal {
126126
* }
127127
* ```
128128
* @examples
129+
* Fetch a resource from context.
130+
* ```ts title=pages/[[...slug]].tsx
131+
* export async function getStaticProps(context) {
132+
* const node = await drupal.getResourceFromContext("node--page", context)
129133
*
134+
* return {
135+
* props: {
136+
* node,
137+
* },
138+
* }
139+
* }
140+
* ```
141+
* Fetch a resource from context in a sub directory.
142+
* ```ts title=pages/articles/[[...slug]].tsx
143+
* export async function getStaticProps(context) {
144+
* const node = await drupal.getResourceFromContext("node--page", context, {
145+
* pathPrefix: "/articles",
146+
* })
147+
*
148+
* return {
149+
* props: {
150+
* node,
151+
* },
152+
* }
153+
* }
154+
* ```
130155
* Using DrupalNode type:
131156
* ```ts
132157
* import { DrupalNode } from "next-drupal"

0 commit comments

Comments
 (0)