Skip to content

Commit cbe0eab

Browse files
committed
docs: add reference examples to translatePathFromContext
1 parent 4c5f95a commit cbe0eab

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,17 @@ export class NextDrupalPages extends NextDrupal {
333333
/**
334334
* Translates a path from the context.
335335
*
336-
* @param {GetStaticPropsContext} context The static props context.
336+
* @param {GetStaticPropsContext} context The context from `getStaticProps` or `getServerSideProps`.
337337
* @param {Object} options Options for the request.
338338
* @returns {Promise<DrupalTranslatedPath | null>} The translated path.
339+
* @requires Decoupled Router module
340+
* @example
341+
* Get info about a path from `getStaticProps` context
342+
* ```ts
343+
* export async function getStaticProps(context) {
344+
* const path = await drupal.translatePathFromContext(context)
345+
* }
346+
* ```
339347
*/
340348
async translatePathFromContext(
341349
context: GetStaticPropsContext,

0 commit comments

Comments
 (0)