twr
@gatsby-project-kb/transformer-wiki-references
npm i @gatsby-project-kb/transformer-wiki-references
twr

@gatsby-project-kb/transformer-wiki-references

Developing gatsby-theme-kb, a Gatsby theme for publishing Knowledge Base.

by hikerpig

0.3.1 (see all)License:MITTypeScript:Not Found
npm i @gatsby-project-kb/transformer-wiki-references
Readme

@gatsby-project-kb/transformer-wiki-references

A gatsby transformer plugin to extract references between markdown nodes. You can then use them to create bi-directional links.

Forked from mathieudutour/gatsby-digital-garden.

An example site for using this plugin is at https://wiki.hikerpig.cn/.

Install

yarn add @gatsby-project-kb/transformer-wiki-references

Usage

// In your gatsby-config.js
module.exports = {
  plugins: [
    // after a markdown or Mdx transformer
    {
      resolve: `@gatsby-project-kb/transformer-wiki-references`,
      options: {
        contentPath: '/home/hikerpig/Notes',
        types: ["Mdx"], // or ["MarkdownRemark"] (or both)
        ignore: [
          '**/.cache/**',
          '**/.github/**',
        ],
      },
    },
  ],
};

Configuration options

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.

How to query for references

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
          }
        }
      }
    }
  }
}

Downloads/wk

35

GitHub Stars

38

LAST COMMIT

6mos ago

MAINTAINERS

1

CONTRIBUTORS

4

OPEN ISSUES

12

OPEN PRs

1
VersionTagPublished
0.3.1
latest
4mos ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate