Source mode
Edit a page's raw MDX, frontmatter included, in a code editor with syntax highlighting and code folding.
Uuendatud 19. nov 20262 min lugemist
Source mode shows the page's raw MDX, frontmatter and all. Use it when you want exact control over the file.
Switching modes
Click Source in the top bar to switch, and Visual to switch back. Both modes edit the same file, and your unsaved changes come with you.
Switching doesn't rewrite your page. When Typemark saves from visual mode, it keeps the parts you didn't edit byte for byte, so a page you also edit in your own editor or on GitHub doesn't pick up surprise diffs.
What you get
- Syntax highlighting for Markdown and for the code inside fenced code blocks
- Line numbers and an active-line highlight
- Code folding from the gutter, to collapse sections under a heading
- Bracket matching and auto-closing brackets and quotes
- Search with
Cmd+F, including replace - Undo and redo with
Cmd+ZandCmd+Shift+Z - Tab to indent
Saving works the same as in visual mode: Typemark saves three seconds after you stop typing, and Cmd+S saves right away. The undo and redo buttons in the top bar belong to visual mode, so use the keyboard here.
What you see
A typical page in source mode:
---
title: "Authentication"
description: "Secure your API with token-based auth."
---
All API requests require a Bearer token in the `Authorization` header.
<Callout type="warning">
Never expose your API key in client-side code.
</Callout>
## Getting a token
```bash
curl -X POST https://api.acme.com/auth/token \
-d '{"email": "[email protected]", "password": "secret"}'
```
Frontmatter
In source mode, frontmatter is part of the file. Edit the YAML between the --- lines directly:
---
title: "My page title"
description: "A brief description for search engines."
icon: "book-open"
---
This is the place for fields the visual editor doesn't show, like icon. Typemark saves your frontmatter exactly as you typed it, keeping your key order and quote style. Title and description changes show up in visual mode when you switch back.
When a page opens here on its own
If the visual editor can't open a page safely, the page opens in source mode with a banner that explains why. Fix the MDX, then click Visual to try again.
When to use which
- You need precise control over the MDX
- You're pasting content from another Markdown source
- You want to edit frontmatter fields beyond the title and description
- You're tracking down a rendering issue
- You'd rather work in a code editor
See Keyboard shortcuts for the full list.