Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

extract-mdx-metadata

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extract-mdx-metadata

Extract MDX metadata without using babel or webpack loaders.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
752
-9.94%
Maintainers
1
Weekly downloads
 
Created
Source

extract-mdx-metadata

Extract MDX metadata without using babel or webpack loaders.

Installation

NPM

$ npm i extract-mdx-metadata

Yarn

$ yarn add extract-mdx-metadata

Usage

Say we have the following file, example.mdx:

import something from 'something';

export const meta = {
    prop: 'value',
};

# Title

Content.

And our script, example.js, looks as follows:

const fs = require('fs');

const extractMdxMeta = require('extract-mdx-metadata');

(async () => {
    const path = 'example/example.mdx';
    const content = fs.readFileSync(path);
    const meta = await extractMdxMeta(content);

    console.log('meta', meta);
})();

Now, running node example yields:

meta {
    prop: 'value'
};

You can try this yourself by downloading or cloning the project, installing dependencies, and running yarn example.

API

extractMdxMeta(content, [options])

Parses content and returns the metadata object.

options

Type: Object

defaultReturnValue

Type: *

Default: {} (empty Object)

The value returned if the content does not contain any metadata.

License

MIT © Michael Novotny

Keywords

extract

FAQs

Package last updated on 08 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts