Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Requirements for extending the Drupal json api for node pages with views to include breadcrumbs and weight.

Task: Add weight and breadcrumbs attributes to node pages.

Using the json api for "Jobs at the Library" Drupal node page as the example. For full: https://dev.lib.umich.edu/web/jsonapi/node/page/68bd39d6-5546-4789-9b3c-0724782b2508

Breadcrumb specs:

  • Start at the homepage.
  • Attach property of breadcrumbs with an array of objects as the value.
  • Each object in the array contains text and to. text is the page title. to is the alias to that page.

Weight specs:

  • The weight of the page corresponding to the order set by Drupal content administrators.
attributes: {
  ...
  breadcrumbs: [
    { text: 'Home', to: '/' },
    { text: 'About Us', to: '/about-us' },
    { text: 'Jobs at the Library', to: '/about-us/jobs-at-library' }
  ],
  weight: 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.