Skip to content

Commit 6162143

Browse files
committed
docs: add reference examples to getPathFromContext
1 parent cbe0eab commit 6162143

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,18 @@ export class NextDrupalPages extends NextDrupal {
365365
}
366366

367367
/**
368-
* Gets the path from the context.
368+
* Return the path (slug) from getStaticProps or getServerSideProps context.
369369
*
370-
* @param {GetStaticPropsContext} context The static props context.
370+
* @param {GetStaticPropsContext} context The context from `getStaticProps` or `getServerSideProps`.
371371
* @param {Object} options Options for the request.
372372
* @returns {string} The constructed path.
373+
* @example
374+
* Get the path (slug) from `getStaticProps` context
375+
* ```ts
376+
* export async function getStaticProps(context) {
377+
* const slug = await drupal.getPathFromContext(context)
378+
* }
379+
* ```
373380
*/
374381
getPathFromContext(
375382
context: GetStaticPropsContext,

0 commit comments

Comments
 (0)