npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gatsby-plugin-md-menus

v0.0.28

Published

gatsby-plugin-md-menus

Readme

gatsby-plugin-md-menus

What is this?

This is a Gatsby plugin that generates hierarchical menus from Markdown (.md) files . It automatically creates a menu based on the directory structure and filenames of your content directory in your gatsby site.

How to Use It

Installation

You can install the gatsby-plugin-md-menus via npm or yarn:

Using npm

npm  install  gatsby-plugin-md-menus

Using yarn

yarn  add  gatsby-plugin-md-menus

##Configuration

After installing the plugin, you need to add it to your gatsby-config.js file. The plugin requires a configuration object to work properly.

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-md-menus',
      options: {
        config: {
          sidebar: {
            forcedNavOrder: [
              '/introduction', // Order of menu items
              '/key-concepts',
            ],
            collapsedNav: [
              '/introduction', // Menu items to collapse
              '/key-concepts',
            ],
          },
          //This is optional 
          gatsby:{
            pathPrefix: "/", // default is '/'
            trailingSlash: false // Default is false 
          }
        }
      }
    }
    // other plugins
  ]
};

Configuration Object

The configuration object defines how your menu items should be structured and displayed. Here's an example configuration:

const config = {
  sidebar: {
    forcedNavOrder: [
      '/introduction', // Order of menu items
      '/key-concepts',
    ],
    collapsedNav: [
      '/introduction', // Menu items to collapse
      '/key-concepts',
    ],
  },
  //This is optional 
  gatsby:{
    pathPrefix: "/", // default is '/'
    trailingSlash: false // Default is false 
  }
};

Folder Structure

For the plugin to work correctly, your content folder should have Markdown files and corresponding directories that match the parent Markdown files. Here is an example structure:

Content

  • introduction folder

  • Contains subcontent related to introduction.md.

  • key-concepts folder

  • Contains subcontent related to key-concepts.md.

Usage

Once the configuration is in place and your content is organized, the plugin will automatically generate the hierarchical menu based on the specified order and collapsed items.

Using the Menu Component

To render the menu in your Gatsby site, you can import and use the Menu component provided by the plugin in your React components. Here's an example of how to do this:

import React, { useState } from 'react';
import Sidemenu from 'gatsby-plugin-md-menus/sidemenu';

const Sidebar = ({setMenu}) => {

  return (
    <Sidemenu onClickMenuItem={setMenu} />
  );
};

export default Sidebar;

Theme Configuration

This configuration allows you to customize the appearance of the side navigation menu and the left sidebar.

The configuration file can be found at:

ROOT_DIRECTORY/src/components/theme/index.js

section: {
  navActiveCol: '#001933', // The text color of an active side menu item.
  navChildCol: 'white',    // The text color of an inactive side menu item.
},

leftSideBar: {
  catTitle: '#004C48',     // The text color of the category title.
  menuHover: '#004C48',    // The background color of a side menu item when hovered.
  menuActive: '#09A4A7',   // The background color of the active side menu item.
  iconNormal: 'white',     // The color of the icons in the side menu.
  iconHover: '#7CC9CD',    // The color of the icons in the side menu when hovered.
}

Contributing

We welcome contributions! Please feel free to submit issues, fork the repository, and make pull requests

License

This project is licensed under the MIT License - see the LICENSE file for details.