Skip to content

Instantly share code, notes, and snippets.

@jonearley
Last active December 13, 2018 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonearley/dc3c48538bb397ad16bf30495d73ed0a to your computer and use it in GitHub Desktop.
Save jonearley/dc3c48538bb397ad16bf30495d73ed0a to your computer and use it in GitHub Desktop.
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