Fix darkmode mermaid theme

* See: https://github.com/next-theme/hexo-theme-next/issues/331
This commit is contained in:
Mimi 2021-09-08 23:44:58 +08:00
parent 0005c0367f
commit debbe5bdc9
3 changed files with 9 additions and 6 deletions

View File

@ -815,7 +815,9 @@ pdf:
mermaid:
enable: false
# Available themes: default | dark | forest | neutral
theme: forest
theme:
light: default
dark: dark
# ---------------------------------------------------------------

View File

@ -14,6 +14,7 @@ hexo.extend.helper.register('next_config', function() {
root : config.root,
images : url_for(theme.images),
scheme : theme.scheme,
darkmode : theme.darkmode,
version : this.next_version,
exturl : theme.exturl,
sidebar : theme.sidebar,

View File

@ -12,14 +12,14 @@ document.addEventListener('page:loaded', () => {
newElement.className = element.className;
element.parentNode.replaceChild(newElement, element);
});
mermaid.init({
theme : CONFIG.mermaid.theme,
logLevel : 3,
mermaid.initialize({
theme : CONFIG.darkmode && window.matchMedia('(prefers-color-scheme: dark)').matches ? CONFIG.mermaid.theme.dark : CONFIG.mermaid.theme.light,
logLevel : 4,
flowchart: { curve: 'linear' },
gantt : { axisFormat: '%m/%d/%Y' },
sequence : { actorMargin: 50 }
}, '.mermaid');
});
mermaid.init();
});
}
});