getPathFromContext
Return the path (slug) from getStaticProps or getServerSideProps context.
const slug = drupal.getPathFromContext( context, options?: { pathPrefix, }): stringcontext: GetStaticPropsContext | GetServerSidePropsContext- Required
- The context from
getStaticPropsorgetServerSideProps.
options- Optional
pathPrefix: string: Set the pathPrefix if you're calling from a subdir. Example: for/articles/[...slug].tsx, usepathPrefix: "/articles".
Examples
- Get the path (slug) from
getStaticPropscontext.
export async function getStaticProps(context) { const slug = await drupal.getPathFromContext(context)}