Description
Package
Not package-specific
Describe the feature request
In Next.js documentation, "slug"
is used as an example of a Dynamic Path Segment of a route. It's a convention in their docs to use slug
if there is only 1 Dynamic Segment in a route. But "slug"
isn't a term has meaning in Next.js.
Unfortunately, Next-Drupal's documentation and APIs sometimes use "slug" as a synonym for "Next.js Dynamic Segment" and sometimes as a synonym for "Drupal path alias". This makes maintaining the software harder because it's hard to tell what the software is supposed to be doing. And I'm sure it makes it hard for API users to know what is expected too.
Examples:
Start by creating a page at
/pages/[...slug].tsx
, where[...slug]
maps to the path alias for an entity type (or content type) in Drupal.
Return the path (slug) from getStaticProps or getServerSideProps context.
Because Path Aliases and Dynamic Segments are both path-related terms it's incredibly important to use the correct term at all times. Using "slug" as synonyms for both makes it even more confusing.
Describe the solution you'd like
Don't use "slug" anywhere unless we are talking about a specific Dynamic Segment in example code.
- The Pages Router/Context -related methods of
DrupalClient
look forcontext.params?.slug
or returnslug
in their data. Since these will be deprecated methods, can we can just leave them be. DrupalClient.preview
andDrupalClient.validateDraftUrl
both look for a "slug" in the search query params sent by the Next Drupal module'sPreviewUrlGenerator
. This should be changed topath
since we are specifically wanting to preview Drupal paths.
Describe alternatives you've considered
I considered adding a dynamicSegmentName
option to the Context-related methods, but if no one has reported this bug yet, why bother fixing?