Last active
April 14, 2021 10:40
-
-
Save johackim/d6ad7bb6b6380959db8789143c5c289f to your computer and use it in GitHub Desktop.
Generate mdx node id from file path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uuid = require("uuid"); | |
const generateNodeId = (filePath) => { | |
const seedConstant = '638f7a53-c567-4eca-8fc1-b23efb1cfb2b'; | |
const gatsbySourceFilesystemNsHash = uuid.v5('gatsby-source-filesystem', seedConstant); | |
const gatsbySourceFilesystemNodeId = uuid.v5(filePath, gatsbySourceFilesystemNsHash); | |
const gatsbyPluginMdxNodeId = `${gatsbySourceFilesystemNodeId} >>> Mdx`; | |
const gatsbyPluginMdxNsHash = uuid.v5('gatsby-plugin-mdx', seedConstant); | |
return uuid.v5(gatsbyPluginMdxNodeId, gatsbyPluginMdxNsHash); | |
}; | |
const filePath = '/home/USER/dev/gatsby-project/content/index.md'; | |
const nodeId = generateNodeId(filePath); | |
console.log(nodeId); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment