Skip to content

Commit

Permalink
feat(#137): config options for toc
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Jul 28, 2024
1 parent 2a4ad40 commit 9f76ce9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
34 changes: 22 additions & 12 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ following optional keys:
How long the server should wait in milliseconds before shutting down after the
last client disconnected; this will be overwritten by the environment variable
`VIV_TIMEOUT` (default is 10000)
- **`"katexOptions"`**\
[Available KaTeX options](https://katex.org/docs/options.html), such as

```json
{
"errorColor": "#cc0000",
"macros": {
"\\RR": "\\mathbb{R}"
}
}
```

- **`"pageTitle"`**\
JavaScript code that will be evaluated to determine the viewer's page title.
Here, the variable `components` is set to a string array of path components
Expand All @@ -53,3 +41,25 @@ following optional keys:
- **`"preferHomeTilde"`**\
Prefer using `~` as a placeholder for your home directory in URLs as well as
the `components` for `"pageTitle"` (default is `true`)
- **`"katexOptions"`**\
[Available KaTeX options](https://katex.org/docs/options.html), such as

```json
{
"errorColor": "#cc0000",
"macros": {
"\\RR": "\\mathbb{R}"
}
}
```

- **`"tocOptions"`**\
[Available options for the table of
contents](https://www.npmjs.com/package/markdown-it-table-of-contents?activeTab=readme#options),
such as

```json
{
"includeLevel": [2, 3]
}
```
7 changes: 5 additions & 2 deletions src/parser/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ type Config = {
dirListIgnore?: string[];
port: number;
timeout: number;
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
katexOptions?: any;
pageTitle?: string;
mdExtensions: string[];
preferHomeTilde: boolean;
// markdown-it plugin options
/* eslint-disable @typescript-eslint/no-explicit-any */
katexOptions?: any;
tocOptions?: any;
/* eslint-enable @typescript-eslint/no-explicit-any */
};

const defaultConfig: Config = {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import attributes from 'markdown-it-attrs';
mdit.use(attributes);
/* @ts-expect-error: module not typed */
import toc from 'markdown-it-table-of-contents';
mdit.use(toc);
mdit.use(toc, config.tocOptions);

// MARK: untyped plugins done

Expand Down

0 comments on commit 9f76ce9

Please sign in to comment.