This is a fork of the @gridsome/transformer-remark
This is needed since I need to add for multiple types of links that needs support. Which when parsed also needs to be used to extend some fields in graphql. From what I can see, this is not possible via remark plugins, or to have multiple transformers for the same file format.
[ ] ==highlight text==
[ ] [[Internal link]]
[ ] [[Internal link|With custom text]]
[ ] [[Internal link#heading]]
[ ] [[Internal link#heading|With custom text]]
[ ] ![[Embed note]]
[ ] ![[Embed note#heading]]
Markdown transformer for Gridsome with Remark.
npm install @gridsome/transformer-remark
yarn add @gridsome/transformer-remark
pnpm install @gridsome/transformer-remark
The transformer is automatically used if installed in your project. Custom transformer options can either be set for each source plugin or globally.
//gridsome.config.js
module.exports = {
plugins: [
{
use: '@gridsome/source-filesystem',
options: {
path: 'blog/**/*.md',
typeName: 'Post',
remark: {
// remark options
}
}
}
],
transformers: {
remark: {
// global remark options
}
}
}
By default this plugin comes with remark-slug
, remark-autolink-headings
, remark-external-links
, remark-squeeze-paragraphs
and remark-fix-guillemets
included. Add any additional Remark plugin with a plugins
option. Included plugins can also be disabled if needed. See more info below.
The following example adds the remark-attr
plugin globally if it is installed in your project.
{
remark: {
plugins: [
'remark-attr'
]
}
}
- Type:
Array
- Default:
[]
Add additional Remark plugins.
{
remark: {
plugins: [
// add plugin without options
'remark-plugin',
// require plugin manually
require('remark-plugin'),
// add plugin with options
['remark-plugin', { /* plugin options */ }]
]
}
}
- Type:
boolean
- Default:
true
Set this option to false
to disable all built-in plugins.
- Type:
object
- Default:
{}
Options to pass through to gray-matter for parsing front matter.
- Type:
boolean
- Default:
true
Remove empty (or white-space only) paragraphs.
- Type:
boolean
- Default:
true
Add target and rel attributes to external links.
- Type:
string
- Default:
'_blank'
- Type:
Array | string
- Default:
['nofollow', 'noopener', 'noreferrer']
- Type:
boolean
- Default:
true
Add anchors to heading.
- Type:
boolean
- Default:
true
Automatically add links to headings. Disabled if slug
is false
.
- Type:
string
- Default:
'icon icon-link'
- Type:
boolean
- Default:
true
Support ASCII guillemets (<<
, >>
) and mapping them to HTML.
- Type:
number
- Default:
75
- Type:
number
- Default:
40
- Type:
string
- Type:
boolean
- Default:
true
- Type:
Object
- Default:
{}
Add additional Remark options.
This allows you to enable/disable gfm
, commonmark
, footnotes
, pedantic
and blocks
.
-
gfm
- Type:
boolean
- Default:
true
- Type:
-
commonmark
- Type:
boolean
- Default:
false
- Type:
-
footnotes
- Type:
boolean
- Default:
false
- Type:
-
pedantic
- Type:
boolean
- Default:
false
- Type:
-
blocks
- Type:
Array | string
- Default: list of block HTML elements
- Type:
{
remark: {
plugins: [
//...
],
config: {
footnotes: true
}
}
}