support for stripping off frontmatter
This commit is contained in:
38
readme.md
38
readme.md
@@ -38,6 +38,28 @@ async function main() {
|
||||
}
|
||||
```
|
||||
|
||||
### Handling Frontmatter
|
||||
|
||||
```ts
|
||||
import { process_frontmatter } from './build';
|
||||
|
||||
const raw_content = `---
|
||||
title: Example Markdown with Frontmatter
|
||||
foo:
|
||||
- bar
|
||||
- baz
|
||||
---
|
||||
|
||||
# This is some markdown
|
||||
`;
|
||||
|
||||
const { frontmatter, markdown } = process_frontmatter(raw_content);
|
||||
|
||||
console.log(frontmatter.title); // "Example Markdown with Frontmatter"
|
||||
console.log(frontmatter.foo); // [ "bar", "baz" ]
|
||||
console.log(markdown); // "\n# This is some markdown\n"
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Command Line Use
|
||||
@@ -46,6 +68,22 @@ async function main() {
|
||||
echo '# This is some markdown' | ./bin/markdown2html --base-url 'https://example.com' > output.html
|
||||
```
|
||||
|
||||
### Handling Frontmatter
|
||||
|
||||
```bash
|
||||
filecontents="---
|
||||
title: Example Markdown with Frontmatter
|
||||
foo:
|
||||
- bar
|
||||
- baz
|
||||
---
|
||||
|
||||
# This is some markdown
|
||||
"
|
||||
|
||||
echo "$filecontents" | ./bin/strip-frontmatter frontmatter.json > markdown.md
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
Reference in New Issue
Block a user