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

front-matter

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

front-matter

Extract YAML front matter from strings

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-3.14%
Maintainers
1
Weekly downloads
 
Created

What is front-matter?

The front-matter npm package is used to parse YAML or JSON front matter from strings, typically used in markdown files. This is useful for extracting metadata from content files.

What are front-matter's main functionalities?

Parsing Front Matter

This feature allows you to parse a string containing front matter and extract the metadata and content separately.

const frontMatter = require('front-matter');
const content = '---\ntitle: Hello World\ndate: 2023-10-01\n---\nThis is the content of the file.';
const parsed = frontMatter(content);
console.log(parsed.attributes); // { title: 'Hello World', date: '2023-10-01' }
console.log(parsed.body); // 'This is the content of the file.'

Custom Delimiters

This feature allows you to specify custom delimiters for the front matter, which is useful if your front matter is not delimited by the default '---'.

const frontMatter = require('front-matter');
const content = '+++\ntitle: Hello World\ndate: 2023-10-01\n+++\nThis is the content of the file.';
const options = { delimiters: '+++' };
const parsed = frontMatter(content, options);
console.log(parsed.attributes); // { title: 'Hello World', date: '2023-10-01' }
console.log(parsed.body); // 'This is the content of the file.'

Other packages similar to front-matter

Keywords

FAQs

Package last updated on 27 Nov 2013

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

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