Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-mdx-frontmatter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-mdx-frontmatter - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

25

dist/index.js

@@ -8,3 +8,2 @@ "use strict";

const toml_1 = require("toml");
const visit = require("unist-util-visit");
/**

@@ -17,13 +16,16 @@ * A remark plugin to expose frontmatter data as named exports.

const remarkMdxFrontmatter = ({ name } = {}) => (ast) => {
const mdast = ast;
const imports = [];
if (name && !estree_util_is_identifier_name_1.name(name)) {
if (name && !(0, estree_util_is_identifier_name_1.name)(name)) {
throw new Error(`If name is specified, this should be a valid identifier name, got: ${JSON.stringify(name)}`);
}
visit(ast, (node) => {
for (const node of mdast.children) {
let data;
const { value } = node;
if (node.type === 'yaml') {
data = js_yaml_1.load(node.value);
data = (0, js_yaml_1.load)(value);
// @ts-expect-error A custom node type may be registered for TOML frontmatter data.
}
else if (node.type === 'toml') {
data = toml_1.parse(node.value);
data = (0, toml_1.parse)(value);
}

@@ -34,6 +36,7 @@ if (data == null) {

if (!name && typeof data !== 'object') {
throw new Error(`Expected frontmatter data to be an object, got:\n${node.value}`);
throw new Error(`Expected frontmatter data to be an object, got:\n${value}`);
}
imports.push({
type: 'mdxjsEsm',
value: '',
data: {

@@ -51,4 +54,4 @@ estree: {

kind: 'const',
declarations: Object.entries(name ? { [name]: data } : data).map(([identifier, value]) => {
if (!estree_util_is_identifier_name_1.name(identifier)) {
declarations: Object.entries(name ? { [name]: data } : data).map(([identifier, val]) => {
if (!(0, estree_util_is_identifier_name_1.name)(identifier)) {
throw new Error(`Frontmatter keys should be valid identifiers, got: ${JSON.stringify(identifier)}`);

@@ -59,3 +62,3 @@ }

id: { type: 'Identifier', name: identifier },
init: estree_util_value_to_estree_1.valueToEstree(value),
init: (0, estree_util_value_to_estree_1.valueToEstree)(val),
};

@@ -69,5 +72,5 @@ }),

});
});
ast.children.unshift(...imports);
}
mdast.children.unshift(...imports);
};
exports.remarkMdxFrontmatter = remarkMdxFrontmatter;
{
"name": "remark-mdx-frontmatter",
"version": "1.0.1",
"version": "1.1.0",
"description": "A remark plugin for converting frontmatter metadata into MDX exports",

@@ -40,33 +40,32 @@ "main": "dist/index.js",

"dependencies": {
"estree-util-is-identifier-name": "^1.1.0",
"estree-util-is-identifier-name": "^1.0.0",
"estree-util-value-to-estree": "^1.0.0",
"js-yaml": "^4.0.0",
"toml": "^3.0.0",
"unist-util-visit": "^2.0.3"
"toml": "^3.0.0"
},
"devDependencies": {
"@types/estree": "^0.0.46",
"@mdx-js/mdx": "^2.0.0-rc.1",
"@types/js-yaml": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"eslint": "^7.21.0",
"eslint-config-remcohaszing": "^3.2.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^32.2.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^7.0.0",
"eslint-config-remcohaszing": "^3.0.0",
"eslint-plugin-eslint-comments": "^3.0.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-jsdoc": "^37.0.0",
"eslint-plugin-jsx-a11y": "^6.0.0",
"eslint-plugin-markdown": "^2.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-sort-destructure-keys": "^1.3.5",
"eslint-plugin-unicorn": "^28.0.2",
"prettier": "^2.2.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.0.0",
"eslint-plugin-sort-destructure-keys": "^1.0.0",
"eslint-plugin-unicorn": "^37.0.0",
"mdast-util-mdx": "^1.0.0",
"prettier": "^2.0.0",
"remark-frontmatter": "^3.0.0",
"tape": "^5.2.2",
"ts-node": "^9.1.1",
"typescript": "^4.2.3",
"unified": "^9.2.1",
"xdm": "^1.4.0"
"tape": "^5.0.0",
"ts-node": "^10.0.0",
"typescript": "^4.0.0",
"unified": "^9.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc