Skip to content

igorskyflyer/npm-strip-yaml-front-matter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

--- Strip YAML front matter ---


๐Ÿฆ“ Strips YAML front matter from a String or a file. ๐Ÿ‘พ




๐Ÿ’– Support further development

I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. โ˜•
Thank you for supporting my efforts! ๐Ÿ™๐Ÿ˜Š


Donate to igorskyflyer

@igorskyflyer



๐Ÿค” Introduction

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.

๐Ÿ•ต๐Ÿผ Usage

Install it by executing:

npm i "@igor.dvlpr/strip-yaml-front-matter"

๐Ÿคน๐Ÿผ API

function stripString(content: string): string

Strips 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): string

Strips 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.


๐Ÿชช License

Licensed under the MIT license which is available here, MIT license.


๐Ÿงฌ Related

@igor.dvlpr/is-rootdir

๐Ÿ”ผ Provides a way to check if the given path is the root drive/directory. โ›”


@igor.dvlpr/recursive-readdir

๐Ÿ“– Provides recursive readdir() and readdirSync() functions. ๐Ÿ“


@igor.dvlpr/extendable-string

๐Ÿฆ€ ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. ๐Ÿช€


@igor.dvlpr/regkeys

๐Ÿ“š An npm package for fetching Windows registry keys. ๐Ÿ—


@igor.dvlpr/zep

๐Ÿง  Zep is a zero-dependency, efficient debounce module. โฐ



Provided by Igor Dimitrijeviฤ‡ (@igorskyflyer).