translatePathFromContext
Fetch info about a Drupal path from getStaticProps or getServerSideProps context.
const path = await drupal.translatePathFromContext( context, options?: { withAuth, pathPrefix, }): Promise<DrupalTranslatedPath>
context: GetStaticPropsContext | GetServerSidePropsContext
- Required
- The context from
getStaticProps
orgetServerSideProps
.
options
- Optional
withAuth: boolean | DrupalClientAuth
:- Set the authentication method to use. See the authentication docs.
- Set to
true
to use the authentication method configured on the client.
pathPrefix: string
: Set the pathPrefix if you're calling from a subdir. Example: for/articles/[...slug].tsx
, usepathPrefix: "/articles"
.
Notes
- The Decoupled Router module is required.
Examples
- Get info about a path from
getStaticProps
context.
export async function getStaticProps(context) { const path = await drupal.translatePathFromContext(context)}