52 lines
912 B
Markdown
52 lines
912 B
Markdown
# EMDY
|
|
|
|
Parse and serialize Markdown files with optional frontmatter
|
|
|
|
## Install
|
|
|
|
Configure your environment to be aware of @endeavorance packages:
|
|
|
|
```toml
|
|
# Bunfig.toml
|
|
[install.scopes]
|
|
endeavorance = "https://git.astral.camp/api/packages/endeavorance/npm/"
|
|
```
|
|
|
|
Then install the package:
|
|
|
|
```sh
|
|
bun add @endeavorance/emdy
|
|
```
|
|
## Usage
|
|
|
|
EMDY exports a top level `EMDY` constant which has two functions:
|
|
|
|
- `EMDY.parse(md: string, markdownKey = "content")`
|
|
- `EMDY.stringify(data: Object, markdownKey = "content")`
|
|
|
|
```typescript
|
|
import EMDY from "@endeavorance/emdy";
|
|
|
|
const myMDFile = `
|
|
---
|
|
tags: ["fancy", "stuff"]
|
|
---
|
|
|
|
This is my markdown document!
|
|
`.trim();
|
|
|
|
const parsed = EMDY.parse(myMDFile);
|
|
|
|
console.log(parsed);
|
|
/*
|
|
{
|
|
content: "This is my markdown document!",
|
|
tags: ["fancy", "stuff"]
|
|
}
|
|
*/
|
|
|
|
const stringified = EMDY.stringify(parsed);
|
|
console.log(stringified);
|
|
// Prints the original document
|
|
```
|