1.0.1 • Published 2 years ago

gatsby-remark-enhanced-wikilink v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Gatsby Remark Enhanced Wikilink

A Gatsby Remark plugin to support Enhanced Wikilink Syntax (e.g., Obsidian Internal Links) for Gatsby ^4.0.0

  • To support file linking and image embedding, use with gatsby-remark-images, gatsby-remark-copy-linked-files and gatsby-source-filesystem
  • To be compatible with gatsby-remark-autolink-headers, the default implementation uses Github Slugger to slugify filenames and headings. This can be configured via setting a new wikilinkToUrl function. For more information, please see Options section below.

Supported Syntax

  • Linking to MD files via [[Internal Link#Heading | Alias]]
  • Linking to other files via [[../path/document.pdf]]
  • Embed Images ![[../images/Hello.png]]
  • Embed Notes ![[Internal Notes]]

Installation

yarn add gatsby-remark-enhanced-wikilink

Usage

Add the plugin to your Gatsby config:

// gatsby-config.js
plugins: [
    {
        resolve: "gatsby-transformer-remark",
        options: {
            plugins: [
                {
                    resolve: 'gatsby-remark-obsidian',
                    options: {
                      stripBrackets: true,
                      imageExtensions: ['png', 'jpg', 'jpeg'],
                      fileFileExtensions: ['png', 'jpg', 'jpeg', 'pdf']
                      // see other options below
                    },
                },
            ]
        }
    },
],

Options

type WikilinkArgs = {
  fileName?: string;
  heading?: string;
  alias?: string;
};

type Options = {
  stripBrackets?: boolean;
  wikilinkToUrl?: (args: WikilinkArgs) => string;
  wikilinkToLinkText?: (args: WikilinkArgs) => string;
  imageExtensions?: Array<string>;
  linkFileExtensions?: Array<string>;
};