-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(add docs for anchor plugin): add docs for anchor plugin
Add docs for anchor plugin
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
section: Plugins | ||
title: Anchor | ||
--- | ||
|
||
<script> | ||
import Code from '$lib/components/code/Code.svelte'; | ||
</script> | ||
|
||
This plugin adds `id` attributes and permalinks to headings. | ||
|
||
## Installation | ||
|
||
<Code> | ||
|
||
``` | ||
npm i @cartamd/plugin-anchor | ||
``` | ||
|
||
</Code> | ||
|
||
## Setup | ||
|
||
### Styles | ||
|
||
Import the default theme, or create you own: | ||
|
||
<Code> | ||
|
||
```ts | ||
import '@cartamd/plugin-anchor/default.css'; | ||
``` | ||
|
||
</Code> | ||
|
||
### Extension | ||
|
||
<Code> | ||
|
||
```svelte | ||
<script> | ||
import { Carta, CartaEditor } from 'carta-md'; | ||
import { anchor } from '@cartamd/plugin-anchor'; | ||
const carta = new Carta({ | ||
extensions: [anchor()] | ||
}); | ||
</script> | ||
<CartaEditor {carta} /> | ||
``` | ||
|
||
</Code> | ||
|
||
## Options | ||
|
||
Here are the options you can pass to `anchor()`: | ||
|
||
```ts | ||
export interface AnchorExtensionOptions { | ||
/** | ||
* Maximum depth of headers to generate anchors for. Defaults to 6. | ||
*/ | ||
maxDepth?: number; | ||
} | ||
``` |