Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-plugin-prefix

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

gatsby-plugin-prefix

Use prefix today, save time tomorrow

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-plugin-prefix

Use prefix today, save time tomorrow

Table of Contents

  • Installation
  • Usage
  • API
  • License

Installation

npm install gatsby-plugin-prefix

Usage

  1. Register plugin

In gatsby-config.js:

module.exports = {
  plugins: [
    ...otherPlugins,

    {
      resolve: "gatsby-plugin-prefix",
      options: {
        tag: "tags",
        category: "categories",
        blog: "articles",
      },
    },
  ],
};

API

usePrefix

function() -> obj

This is a React hook that gives you access to the prefix objects that you declared when registering the plugin.

function MyComponent() {
  const { tag, category, blog } = usePrefix();

  console.log(tag); // --> tags
  console.log(category); // --> categories
  console.log(blog); // --> articles

  return <>{...}</>
}

Use Gatsby Node

This plugin creates a Prefix Gatsby node type. When working inside Gatsby lifecycle (createPages, sourceNodes, etc), you can run a Gatsby GraphQL to get the prefix data:

query {
  allPrefix {
    nodes {
      name
      value
    }
  }
}

License

MIT

Keywords

FAQs

Package last updated on 27 Oct 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc