gatsby-plugin-prefix
Use prefix today, save time tomorrow
Table of Contents
Installation
npm install gatsby-plugin-prefix
Usage
- Register plugin
In gatsby-config.js
:
moduleexports = 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.
{ const tag category blog = ; console; // --> tags console; // --> categories console; // --> 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