This commit is contained in:
James Brumond 2023-04-30 19:01:33 -07:00
parent 21f11dcfd7
commit 7bb0e3a072
Signed by: james
GPG Key ID: E8F2FC44BAA3357A

View File

@ -50,13 +50,13 @@ async function main() {
} }
``` ```
### Handling Frontmatter ### Handling front matter
```ts ```ts
import { process_frontmatter } from '@doc-utils/markdown2html'; import { process_frontmatter } from '@doc-utils/markdown2html';
const raw_content = `--- const raw_content = `---
title: Example Markdown with Frontmatter title: Example Markdown with front matter
foo: foo:
- bar - bar
- baz - baz
@ -67,7 +67,7 @@ foo:
const { frontmatter, markdown } = process_frontmatter(raw_content); const { frontmatter, markdown } = process_frontmatter(raw_content);
console.log(frontmatter.title); // "Example Markdown with Frontmatter" console.log(frontmatter.title); // "Example Markdown with front matter"
console.log(frontmatter.foo); // [ "bar", "baz" ] console.log(frontmatter.foo); // [ "bar", "baz" ]
console.log(markdown); // "\n# This is some markdown\n" console.log(markdown); // "\n# This is some markdown\n"
``` ```
@ -80,11 +80,11 @@ console.log(markdown); // "\n# This is some markdown\n"
echo '# This is some markdown' | ./bin/markdown2html --base-url 'https://example.com' > output.html echo '# This is some markdown' | ./bin/markdown2html --base-url 'https://example.com' > output.html
``` ```
### Handling Frontmatter ### Handling front matter
```bash ```bash
filecontents="--- filecontents="---
title: Example Markdown with Frontmatter title: Example Markdown with front matter
foo: foo:
- bar - bar
- baz - baz