getStaticPathsFromContext

Return paths for getStaticPaths.


const paths = await drupal.getStaticPathsFromContext(
types,
context,
options?: {
params,
withAuth,
pathPrefix,
}
): Promise<GetStaticPathsResult<{ slug: string[] }>["paths"]>
  • types: string | string[]
    • Required
    • The resource types. Example: node--article or ["taxonomy_term--tags", "user--user"].
  • context: GetStaticPathsContext
    • Required
    • The context from getStaticPaths.
  • options
    • Optional
    • params: JsonApiParams: JSON:API params such as filter, fields, include or sort.
    • 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, use pathPrefix: "/articles".

Examples

  • Return static paths for node--page resources.
export async function getStaticPaths(context) {
return {
paths: await drupal.getStaticPathsFromContext("node--page", context),
fallback: "blocking",
}
}
  • Return static paths for node--page and node--article resources.
export async function getStaticPaths(context) {
return {
paths: await drupal.getStaticPathsFromContext(
["node--page", "node--article"],
context
),
fallback: "blocking",
}
}