Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorskyflyer/npm-strip-yaml-front-matter
π¦ Strips YAML front matter from a String or a file. πΎ
https://github.com/igorskyflyer/npm-strip-yaml-front-matter
back-end biome esm file front-matter frontmatter igorskyflyer javascript js path regex regexp string ts typescript vitest yaml
Last synced: 3 days ago
JSON representation
π¦ Strips YAML front matter from a String or a file. πΎ
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-strip-yaml-front-matter
- Owner: igorskyflyer
- License: mit
- Created: 2024-07-09T23:05:38.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-07-10T16:58:01.000Z (3 months ago)
- Last Synced: 2024-09-20T14:16:25.019Z (7 days ago)
- Topics: back-end, biome, esm, file, front-matter, frontmatter, igorskyflyer, javascript, js, path, regex, regexp, string, ts, typescript, vitest, yaml
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/strip-yaml-front-matter
- Size: 29.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
--- 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! ππ
@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`
```yaml
---
author: John Doe
publishDate: 27 Aug, 2024
---Some Markdown content.
```
## π΅πΌ Usage
Install it by executing:
```shell
npm i "@igor.dvlpr/strip-yaml-front-matter"
```
## π€ΉπΌ API
```ts
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.
```ts
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](https://github.com/igorskyflyer/npm-strip-yaml-front-matter/blob/main/LICENSE).
---
## 𧬠Related
[@igor.dvlpr/is-rootdir](https://www.npmjs.com/package/@igor.dvlpr/is-rootdir)
> _πΌ Provides a way to check if the given path is the root drive/directory. β_
[@igor.dvlpr/recursive-readdir](https://www.npmjs.com/package/@igor.dvlpr/recursive-readdir)
> _π Provides recursive readdir() and readdirSync() functions. π_
[@igor.dvlpr/extendable-string](https://www.npmjs.com/package/@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](https://www.npmjs.com/package/@igor.dvlpr/regkeys)
> _π An npm package for fetching Windows registry keys. π_
[@igor.dvlpr/zep](https://www.npmjs.com/package/@igor.dvlpr/zep)
> _π§ Zep is a zero-dependency, efficient debounce module. β°_
>
> Provided by **Igor DimitrijeviΔ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).
>