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 asfilter
,fields
,include
orsort
.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"
.
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
andnode--article
resources.
export async function getStaticPaths(context) { return { paths: await drupal.getStaticPathsFromContext( ["node--page", "node--article"], context ), fallback: "blocking", }}