@dww/gatsby-remark-graphql
Advanced tools
Comparing version 1.0.1 to 1.0.2
40
index.js
const RemarkPlugin = require('@dww/remark-plugin-graphql'); | ||
module.exports = ({markdownAST}, opts) => { | ||
const transformer = RemarkPlugin(opts); | ||
return transformer(markdownAST); | ||
// From https://github.com/jxson/front-matter/blob/master/index.js | ||
var optionalByteOrderMark = '\\ufeff?'; | ||
var platform = typeof process !== 'undefined' ? process.platform : ''; | ||
var pattern = '^(' + | ||
optionalByteOrderMark + | ||
'(= yaml =|---)' + | ||
'$([\\s\\S]*?)' + | ||
'^(?:\\2|\\.\\.\\.)\\s*' + | ||
'$' + | ||
(platform === 'win32' ? '\\r?' : '') + | ||
'(?:\\n)?)'; | ||
// NOTE: If this pattern uses the 'g' flag the `regex` variable definition will | ||
// need to be moved down into the functions that use it. | ||
var frontmatterRegex = new RegExp(pattern, 'm'); | ||
function markdownOffset({markdownAST, markdownNode}) { | ||
const match = frontmatterRegex.exec(markdownNode.rawBody || ''); | ||
if (!match) { | ||
return 0; | ||
} | ||
const lines = match[match.length - 1].split(/\r\n|[\n\r]/g); | ||
return lines.length; | ||
} | ||
module.exports = ( | ||
{markdownAST, markdownNode, reporter, ...gatsbyOpts}, | ||
opts, | ||
) => { | ||
const transformer = RemarkPlugin({ | ||
...opts, | ||
markdownOffset: markdownOffset({markdownAST, markdownNode}), | ||
}); | ||
try { | ||
return transformer(markdownAST); | ||
} catch (e) { | ||
reporter.error(e); | ||
} | ||
}; |
{ | ||
"name": "@dww/gatsby-remark-graphql", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -12,4 +12,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@dww/remark-plugin-graphql": "1.0.1" | ||
"@dww/remark-plugin-graphql": "1.0.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
1443
37
0
+ Added@dww/remark-plugin-graphql@1.0.2(transitive)
- Removed@dww/remark-plugin-graphql@1.0.1(transitive)