Gatsby Book Launch

“The missing guide to the modern web” launches on Thursday, Sep 29th: Modular: The Web’s New Architecture

ContactSign Up for Free
Community Plugin
View plugin on GitHub

gatsby-source-strapi-plugin-navigation-v2

This plugin sources the strapi-plugin-navigation.

Install

yarn:

yarn add gatsby-source-strapi-plugin-navigation-v2

npm:

npm install gatsby-source-strapi-plugin-navigation-v2

How to use

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-strapi-plugin-navigation-v2",
      options: {
        apiURL: "localhost:1337",
        navigationIdsOrSlugs: [
          "api/navigation/render/1"
        ],
        type: "tree", // optional
        token: "strapi_token" // optional
      }
    }
  ]
}

Alternatively you can use an object with keys that will later map to the navigation items via the key property.

navigationIdsOrSlugs: {
  mainMenu: "api/navigation/render/1"
}

If everything works correctly you should be able to view an allStrapiNavigation option inside GraphiQL.

Example of allStrapiNavigation option in GraphiQL

Credits

Heavily inspired by edardev’s sourcing plugin.

© 2022 Gatsby, Inc.