forked from openRin/Rin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: use Mermaid * chore: use loadash to debounce rendering * chore: update lockfile
- Loading branch information
1 parent
f12910d
commit 7bdaf76
Showing
6 changed files
with
82 additions
and
3 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,26 @@ | ||
import type { Plugin } from 'unified'; | ||
import type { Content, Root } from 'mdast'; | ||
|
||
function processNode(child: Content, index: number, siblings: Content[]) { | ||
if (child.type !== 'code') { | ||
if ('children' in child) { | ||
child.children.map(processNode); | ||
} | ||
return; | ||
} | ||
const { lang, value } = child; | ||
if (lang !== 'mermaid') return; | ||
siblings[index] = { | ||
type: 'html', | ||
value: ` | ||
<pre class="mermaid_default dark:hidden">${value}</pre> | ||
<pre class="mermaid_dark dark:block hidden">${value}</pre> | ||
` | ||
} | ||
} | ||
|
||
const remarkMermaid: Plugin<[], Root> = () => (root: Root) => { | ||
root.children.map(processNode) | ||
}; | ||
|
||
export default remarkMermaid; |
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