```space-script
silverbullet.registerEventListener({name: "editor:pageLoaded"}, async () => {
const text = await editor.getText();
if(!text.startsWith("---")) {
console.log("No frontmatter, skipping folding");
return;
}
const pos = await editor.getCursor();
await editor.moveCursor(0);
await editor.fold();
await editor.moveCursor(pos);
console.log("Folded frontmatter.")
});
```
Seems to do it. It may have a side effect of always scrolling the page a bit, depending on the cursor position, but perhaps that’s acceptable.