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--articleor["taxonomy_term--tags", "user--user"].
context: GetStaticPathsContext- Required
- The context from
getStaticPaths.
options- Optional
params: JsonApiParams: JSON:API params such asfilter,fields,includeorsort.withAuth: boolean | DrupalClientAuth:- Set the authentication method to use. See the authentication docs.
- Set to
trueto 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".
Examples
- Return static paths for
node--pageresources.
export async function getStaticPaths(context) { return { paths: await drupal.getStaticPathsFromContext("node--page", context), fallback: "blocking", }}- Return static paths for
node--pageandnode--articleresources.
export async function getStaticPaths(context) { return { paths: await drupal.getStaticPathsFromContext( ["node--page", "node--article"], context ), fallback: "blocking", }}