src | ||
.gitignore | ||
biome.json | ||
build.ts | ||
bun.lock | ||
LICENSE | ||
package.json | ||
README.md | ||
tsconfig.json |
EMDY
Parse and serialize Markdown files with optional frontmatter
Install
Configure your environment to be aware of @endeavorance packages:
# Bunfig.toml
[install.scopes]
endeavorance = "https://git.astral.camp/api/packages/endeavorance/npm/"
Then install the package:
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")
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