A gatsby transformer plugin to extract references between markdown nodes. You can then use them to create bi-directional links.
An example site for using this plugin is at https://notes.billgo.me/.
yarn add gatsby-transformer-wiki-references
// In your gatsby-config.js
module.exports = {
plugins: [
// after a markdown or Mdx transformer
{
resolve: `gatsby-transformer-wiki-references`,
options: {
contentPath: '/home/notes',
types: ["Mdx"], // or ["MarkdownRemark"] (or both)
ignore: [
'**/.cache/**',
'**/.github/**',
],
},
},
],
};
contentPath
[string][optional]
The path to directory of your notes, if there are nested folders in your notes, it's recommended that this option is provided so the plugin can resolve the references correctly.
types
[Array][optional]
The types of the nodes to transform. Defaults to ['Mdx']
ignore
[Array][optional]
Will be used along with contentPath
, to filter out those files you want to ignore. Accepts globs or regexps, any format that's supported by anymatch.
Two types of references are available: outboundReferences
and inboundReferences
.
The fields will be created in your site's GraphQL schema on the nodes of types specified in the options.
{
allMdx {
outboundReferences {
... on Mdx {
id
parent {
id
}
}
}
inboundReferences {
... on Mdx {
id
parent {
id
... on RoamPage {
title
}
}
}
}
}
}