Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
feat(mermaid): improve mermaid style and render
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed Nov 23, 2019
1 parent b20fe1b commit 2578aba
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 332 deletions.
5 changes: 5 additions & 0 deletions assets/css/_page/_post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@
@import "../_partial/_post/admonition";

.mermaid {
width: 100%;
margin: 3% auto;
text-align: center;

@import "../_mermaid/neutral/index";

.dark-theme & {
Expand All @@ -364,6 +368,7 @@
height: 0;
padding-bottom: 75%;
margin: 3% auto;
text-align: center;

iframe {
position: absolute;
Expand Down
24 changes: 19 additions & 5 deletions assets/js/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jQuery(function($) {
_Blog.dynamicToTop = function() {
const min = 300;
var $toTop = $('#dynamic-to-top');
$(window).scroll(function() {
$(window).scroll(() => {
var scrollTop = $(window).scrollTop();
if (typeof document.body.style.maxHeight === 'undefined') {
$toTop.css({
Expand Down Expand Up @@ -103,7 +103,6 @@ jQuery(function($) {
&& (temp = newTocList.children[0].children[0]).tagName === 'UL') {
newTocList = temp;
}

if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList);
};

Expand Down Expand Up @@ -220,19 +219,33 @@ jQuery(function($) {
}
};

_Blog.mermaid = function() {
if (window.mermaidMap) {
const mermaidAPI = mermaid.mermaidAPI
Object.keys(mermaidMap).forEach((id) => {
const element = document.getElementById(id);
mermaidAPI.render("d" + id, mermaidMap[id], (svgCode) => {
element.innerHTML = svgCode;
const svg = element.firstChild;
svg.style.width = "100%"
}, element);
});
}
}

_Blog.echarts = function() {
if (window.echartsMap) {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].dispose();
}
echartsArr = [];
Object.keys(echartsMap).forEach(function(id) {
Object.keys(echartsMap).forEach((id) => {
let myChart = echarts.init(document.getElementById(id), window.isDark ? 'dark' : 'macarons', {renderer: 'svg'});
myChart.setOption(echartsMap[id]);
echartsArr.push(myChart);
});
window.addEventListener("resize", function() {
this.setTimeout(function(){
this.setTimeout(() => {
for (let i = 0; i < echartsArr.length; i++) {
echartsArr[i].resize();
}
Expand Down Expand Up @@ -275,13 +288,14 @@ jQuery(function($) {
}
};

$(document).ready(function() {
$(document).ready(() => {
_Blog.toggleMobileMenu();
_Blog.toggleTheme();
_Blog.changeTitle();
_Blog.dynamicToTop();
_Blog.chroma();
_Blog.responsiveTable();
_Blog.mermaid();
_Blog.echarts();
_Blog.countdown();
_Blog.typeit();
Expand Down
299 changes: 0 additions & 299 deletions exampleSite/zh/content/posts/test.md

This file was deleted.

Loading

0 comments on commit 2578aba

Please sign in to comment.