Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid support #649

Merged
merged 7 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,16 @@ tabs:
labels: true
border_radius: 0

# Mermaid tag
mermaid:
enable: false
# Available themes: default | dark | forest | neutral
theme: forest
# Use 8.0.0 as default, jsdelivr as default CDN, works everywhere even in China
cdn: //cdn.jsdelivr.net/npm/mermaid@8.0.0/dist/mermaid.min.js
stevenjoezhang marked this conversation as resolved.
Show resolved Hide resolved
# CDNJS, provided by cloudflare, maybe the best CDN, but not works in China
#cdn: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js


#! ---------------------------------------------------------------
#! DO NOT EDIT THE FOLLOWING SETTINGS
Expand All @@ -833,16 +843,16 @@ motion:
sidebar: slideUpIn

# Fancybox. There is support for old version 2 and new version 3.
# Choose only any one variant, do not need to install both.
# Choose only one variant, do not need to install both.
# To install 2.x: https://github.com/theme-next/theme-next-fancybox
# To install 3.x: https://github.com/theme-next/theme-next-fancybox3
fancybox: false

# Added switch option for separated repo in 6.0.0.
# Polyfill to remove click delays on browsers with touch UIs.
# Dependencies: https://github.com/theme-next/theme-next-fastclick
fastclick: false

# Added switch option for separated repo in 6.0.0.
# Vanilla JavaScript plugin for lazyloading images.
# Dependencies: https://github.com/theme-next/theme-next-jquery-lazyload
lazyload: false

Expand Down
1 change: 1 addition & 0 deletions layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
{% include '_third-party/analytics/firestore.swig' %}
{% include '_third-party/math/index.swig' %}
{% include '_third-party/pdf.swig' %}
{% include '_third-party/mermaid.swig' %}
{% include '_third-party/baidu-push.swig' %}
{% include '_third-party/schedule.swig' %}
{% include '_third-party/needsharebutton.swig' %}
Expand Down
21 changes: 21 additions & 0 deletions layout/_third-party/mermaid.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% if theme.mermaid.enable %}
<script>
if ($('body').find('pre.mermaid').length) {
$.ajax({
type: 'GET',
url: '{{ theme.mermaid.cdn }}',
dataType: 'script',
cache: true,
success: function() {
mermaid.initialize({
theme: '{{ theme.mermaid.theme }}',
logLevel: 3,
flowchart: { curve: 'linear' },
gantt: { axisFormat: '%m/%d/%Y' },
sequence: { actorMargin: 50 }
});
}
});
}
</script>
{% endif %}
16 changes: 16 additions & 0 deletions scripts/tags/mermaid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* mermaid.js | https://theme-next.org/docs/tag-plugins/mermaid/
*/

/* global hexo */

'use strict';

function mermaid(args, content) {
return `<pre class="mermaid" style="text-align: center;">
${args.join(' ')}
${content}
</pre>`;
}

hexo.extend.tag.register('mermaid', mermaid, {ends: true});
1 change: 1 addition & 0 deletions source/js/src/js.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/

;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
Expand Down