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
andgatsby-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 newwikilinkToUrl
function. For more information, please seeOptions
section below.
- 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]]
yarn add gatsby-remark-enhanced-wikilink
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'],
linkFileExtensions: ['png', 'jpg', 'jpeg', 'pdf']
// see other options below
},
},
]
}
},
],
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>;
};