Skip to content

Commit

Permalink
docs: add remaining examples to getResourceFromContext typedoc
Browse files Browse the repository at this point in the history
  • Loading branch information
backlineint committed Jan 23, 2025
1 parent 27cd1b7 commit 1509e09
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/next-drupal/src/next-drupal-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,32 @@ export class NextDrupalPages extends NextDrupal {
* }
* ```
* @examples
* Fetch a resource from context.
* ```ts title=pages/[[...slug]].tsx
* export async function getStaticProps(context) {
* const node = await drupal.getResourceFromContext("node--page", context)
*
* return {
* props: {
* node,
* },
* }
* }
* ```
* Fetch a resource from context in a sub directory.
* ```ts title=pages/articles/[[...slug]].tsx
* export async function getStaticProps(context) {
* const node = await drupal.getResourceFromContext("node--page", context, {
* pathPrefix: "/articles",
* })
*
* return {
* props: {
* node,
* },
* }
* }
* ```
* Using DrupalNode type:
* ```ts
* import { DrupalNode } from "next-drupal"
Expand Down

0 comments on commit 1509e09

Please sign in to comment.