@igorskyflyer/strip-yaml-front-matter
v1.1.1
Published
🦓 Strips YAML front matter from a String or a file. 👾
Downloads
2
Maintainers
Readme
📃 Table of Contents
🤖 Features
- 🧹 Remove YAML front matter from any string
- 📄 Clean YAML front matter from files directly
- ⚡ Simple, fast, regex‑powered stripping
- 🚫 Handles invalid input gracefully
- 🔒 Throws clear errors on bad file paths
- 📝 Keeps only the meaningful content
- 🛠 Works out‑of‑the‑box, zero dependencies
🕵🏼 Usage
Install it by executing any of the following, depending on your preferred package manager:
pnpm add @igorskyflyer/strip-yaml-front-matteryarn add @igorskyflyer/strip-yaml-front-matternpm i @igorskyflyer/strip-yaml-front-matter🤹🏼 API
YAML front matter is a special text/code block placed between two triple-dashed lines that is added to the top of a file, usually Markdown (.md), sometimes even HTML (.html) files and provides meta data about the given file or provide means to do additional processing of the file. It is mostly used by static site generators (SSG) or content management systems (CMS).
Here's an example Markdown file:
example.md
---
author: John Doe
publishDate: 27 Aug, 2024
---
Some Markdown content.function stripString(content: string): stringStrips YAML front matter from a String.
content:string, the string whose YAML front matter to strip.
Returns the original String without the YAML front matter.
function stripFile(path: string): stringStrips YAML front matter from a file.
path:string, the path to the file.
⚠️ WARNING
Will throw an error if the file path is not valid or the file cannot be read.
Returns the original file contents as a String without the YAML front matter.
📝 Changelog
📑 The changelog is available here, CHANGELOG.md.
🪪 License
Licensed under the MIT license which is available here, MIT license.
💖 Support
🧬 Related
🔼 Provides a way to check if the given path is the root drive/directory. ⛔
@igorskyflyer/recursive-readdir
📖 Provides recursive readdir() and readdirSync() functions. 📁
@igorskyflyer/extendable-string
🦀 ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. 🪀
📚 An npm package for fetching Windows registry keys. 🗝
🧠 Zep is a zero-dependency, efficient debounce module. ⏰
👨🏻💻 Author
Created by Igor Dimitrijević (@igorskyflyer).
