New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

frontity-menu

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frontity-menu

Frontity Menu

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

frontity-menu

This package helps fetch the menu from wordpress. It requires setup in both wordpress and frontity.

Wordpress

Theme

In the theme we need to define the nav menus.


 register_nav_menus([
        'primary_menu' => __('Primary Menu', 'brs'),
        'footer_menu' => __('Footer Menu', 'brs'),
    ]);

Plugins

Also we need to expose an endpoint via the plugin wp-rest-api-v2-menus

To install the plugin use: wp plugin install wp-rest-api-v2-menus --activate

Postman

To test if this works expect with a GET request.

https://example.com/wp-json/menus/v1/locations/${slug}

Setup Frontity

npm i frontity-menu

In frontity.settings.js add:


{
  name: "frontity-menu",
  state: {
    frontityMenu: {
      menuSlugs: ["primary_menu"] 
    }
  },
},

Usage


  import { MenuData } from "frontity-menu/types"


  const { items } = state.source.get("/menus/primary_menu/") as MenuData

  return (
    <>
      {Object.entries(items).map(([key, item]) => {
        const { url, title } = item;
        const link = libraries.source.normalize(url);
        return (
            <Link
                key={key}
                link={link}
                aria-current={ariaCurrent}
                onClick={() => closeMobileMenu()}
                >
                {title}
             </Link>
        );
      })}
    </>
  );

FAQs

Package last updated on 03 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts