Skip to content

Commit 16f3109

Browse files
committed
fix issue with front-matter being rendered
1 parent 8592c96 commit 16f3109

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ __tests__/ → Vitest browser-mode tests (Playwright)
6464
- Output format is ES modules with `.jsx` suffix, compiled in-source (`.jsx` files sit alongside `.res` files).
6565
- Reference the abridged documentation for clarification on how ReScript's APIs work: https://rescript-lang.org/llms/manual/llm-small.txt
6666
- If you need more information you can access the full documentation, but do this only when needed as the docs are very large: https://rescript-lang.org/llms/manual/llm-full.txt
67+
- Never use `%raw` unless you are specifically asked to
68+
- Never use `Object.magic`
69+
- Don't add type annotations unless necessary for clarity or to resolve an error. ReScript's type inference is powerful, and often explicit annotations are not needed.
6770

6871
### ReScript Dependencies
6972

src/common/MarkdownParser.res

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ type result = {
2727

2828
let vfileMatterPlugin = makePlugin(_options => (_tree, vfile) => vfileMatter(vfile))
2929

30+
type remarkNode = {@as("type") type_: string}
31+
type remarkTree = {mutable children: array<remarkNode>}
32+
33+
let stripFrontmatterPlugin = makePlugin(_options =>
34+
(tree, _vfile) => {
35+
tree.children = tree.children->Array.filter(node => node.type_ !== "yaml")
36+
}
37+
)
38+
3039
let parser =
3140
make()
3241
->use(remarkParse)
@@ -35,6 +44,7 @@ let parser =
3544
->use(remarkComment)
3645
->useOptions(remarkFrontmatter, [{"type": "yaml", "marker": "-"}])
3746
->use(vfileMatterPlugin)
47+
->use(stripFrontmatterPlugin)
3848

3949
let parseSync = content => {
4050
let vfile = parser->processSync(content)

0 commit comments

Comments
 (0)