Initial commit
This commit is contained in:
commit
c75752b1b7
10 changed files with 387 additions and 0 deletions
51
README.md
Normal file
51
README.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
# 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
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue