diff --git a/_config.yml b/_config.yml index 5ec03f156a..4d0ddcb140 100644 --- a/_config.yml +++ b/_config.yml @@ -506,7 +506,7 @@ font: # - CDNJS (cdnjs.cloudflare.com), provided by cloudflare # --------------------------------------------------------------- -# Math Equations Render Support +# Math Formulas Render Support math: enable: false @@ -515,28 +515,17 @@ math: # If you set it to false, it will load mathjax / katex srcipt EVERY PAGE. per_page: true - engine: mathjax - #engine: katex - # hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support. mathjax: - cdn: //cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML - #cdn: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML - + enable: false # See: https://mhchem.github.io/MathJax-mhchem/ - #mhchem: //cdn.jsdelivr.net/npm/mathjax-mhchem@3 - #mhchem: //cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.0 + mhchem: false # hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) required for full Katex support. katex: - cdn: //cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css - #cdn: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css - - copy_tex: - # See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex - enable: false - copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js - copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css + enable: false + # See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex + copy_tex: false # Easily enable fast Ajax navigation on your website. # Dependencies: https://github.com/theme-next/theme-next-pjax @@ -936,17 +925,12 @@ pdf: enable: false # Default height height: 500px - pdfobject: - cdn: //cdn.jsdelivr.net/npm/pdfobject@2/pdfobject.min.js - #cdn: //cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js # Mermaid tag mermaid: enable: false # Available themes: default | dark | forest | neutral theme: forest - cdn: //cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js - #cdn: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js # --------------------------------------------------------------- @@ -1038,6 +1022,25 @@ vendors: # fontawesome: //cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css fontawesome: + # MathJax + # Example: + # mathjax: //cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML + # mathjax: //cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML + # mhchem: //cdn.jsdelivr.net/npm/mathjax-mhchem@3 + # mhchem: //cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.0 + mathjax: + mhchem: + + # KaTeX + # Example: + # katex: //cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css + # katex: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css + # copy_tex_js: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js + # copy_tex_css: //cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css + katex: + copy_tex_js: + copy_tex_css: + # Internal version: 0.2.8 # Example: # pjax: //cdn.jsdelivr.net/gh/theme-next/theme-next-pjax@0/pjax.min.js @@ -1125,6 +1128,18 @@ vendors: algolia_instant_js: algolia_instant_css: + # PDF + # Example: + # pdfobject: //cdn.jsdelivr.net/npm/pdfobject@2/pdfobject.min.js + # pdfobject: //cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js + pdfobject: + + # Mermaid + # Example: + # mermaid: //cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js + # mermaid: //cdnjs.cloudflare.com/ajax/libs/mermaid/8.0.0/mermaid.min.js + mermaid: + # Internal version: 1.2.1 # Example: # velocity: //cdn.jsdelivr.net/npm/velocity-animate@1/velocity.min.js diff --git a/layout/_partials/head/head.swig b/layout/_partials/head/head.swig index c483920608..7e233adc25 100644 --- a/layout/_partials/head/head.swig +++ b/layout/_partials/head/head.swig @@ -49,47 +49,29 @@ {{ next_font() }} -{%- set font_awesome_uri = url_for(theme.vendors._internal + '/font-awesome/css/font-awesome.min.css?v=4.7.0') %} -{%- if theme.vendors.fontawesome %} - {%- set font_awesome_uri = theme.vendors.fontawesome %} -{%- endif %} +{%- set font_awesome_uri = theme.vendors.fontawesome | default(url_for(theme.vendors._internal + '/font-awesome/css/font-awesome.min.css?v=4.7.0')) %} {%- if theme.fancybox %} - {%- set fancybox_css_uri = url_for(theme.vendors._internal + '/fancybox/source/jquery.fancybox.css') %} - {%- if theme.vendors.fancybox_css %} - {%- set fancybox_css_uri = theme.vendors.fancybox_css %} - {%- endif %} + {%- set fancybox_css_uri = theme.vendors.fancybox_css | default(url_for(theme.vendors._internal + '/fancybox/source/jquery.fancybox.css')) %} {%- endif %} {%- if theme.likely.enable %} - {%- set likely_css_url = '//cdn.jsdelivr.net/npm/ilyabirman-likely@2/release/likely.css' %} - {%- if theme.vendors.likely_css %} - {%- set likely_css_url = theme.vendors.likely_css %} - {%- endif %} - + {%- set likely_css_uri = theme.vendors.likely_css | default('//cdn.jsdelivr.net/npm/ilyabirman-likely@2/release/likely.css') %} + {%- endif %} {%- if theme.needmoreshare2.enable %} - {%- set needmoreshare2_css = url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.css') %} - {%- if theme.vendors.needmoreshare2_css %} - {%- set needmoreshare2_css = theme.vendors.needmoreshare2_css %} - {%- endif %} - + {%- set needmoreshare2_css_uri = theme.vendors.needmoreshare2_css | default(url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.css')) %} + {%- endif %} {%- if theme.pace.enable %} - {%- set pace_css_uri = url_for(theme.vendors._internal + '/pace/pace-theme-'+ theme.pace.theme +'.min.css?v=1.0.2') %} - {%- set pace_js_uri = url_for(theme.vendors._internal + '/pace/pace.min.js?v=1.0.2') %} - {%- if theme.vendors.pace %} - {%- set pace_js_uri = theme.vendors.pace %} - {%- endif %} - {%- if theme.vendors.pace_css %} - {%- set pace_css_uri = theme.vendors.pace_css %} - {%- endif %} - + {%- set pace_css_uri = theme.vendors.pace_css | default(url_for(theme.vendors._internal + '/pace/pace-theme-' + theme.pace.theme + '.min.css?v=1.0.2')) %} + {%- set pace_js_uri = theme.vendors.pace | default(url_for(theme.vendors._internal + '/pace/pace.min.js?v=1.0.2')) %} + {%- endif %} {# Export some HEXO Configurations to Front-End #} diff --git a/layout/_partials/share/likely.swig b/layout/_partials/share/likely.swig index 5e7a3ca893..42b40f1142 100644 --- a/layout/_partials/share/likely.swig +++ b/layout/_partials/share/likely.swig @@ -1,5 +1,2 @@ -{%- set likely_js_url = '//cdn.jsdelivr.net/npm/ilyabirman-likely@2/release/likely.js' %} -{%- if theme.vendors.likely_js %} - {%- set likely_js_url = theme.vendors.likely_js %} -{%- endif %} - +{%- set likely_js_uri = theme.vendors.likely_js | default('//cdn.jsdelivr.net/npm/ilyabirman-likely@2/release/likely.js') %} + diff --git a/layout/_partials/share/needsharebutton.swig b/layout/_partials/share/needsharebutton.swig index 8b4075c4d7..a183a69f52 100644 --- a/layout/_partials/share/needsharebutton.swig +++ b/layout/_partials/share/needsharebutton.swig @@ -6,11 +6,8 @@ {%- endif %} -{%- set needmoreshare2_js = url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.js') %} -{%- if theme.vendors.needmoreshare2_js %} - {%- set needmoreshare2_js = theme.vendors.needmoreshare2_js %} -{%- endif %} - +{%- set needmoreshare2_js_uri = theme.vendors.needmoreshare2_js | default(url_for(theme.vendors._internal + '/needsharebutton/needsharebutton.js')) %} + {%- endif %} {%- if theme.canvas_ribbon.enable %} - {%- set canvas_ribbon_uri = url_for(theme.vendors._internal + '/canvas-ribbon/canvas-ribbon.js') %} - {%- if theme.vendors.canvas_ribbon %} - {%- set canvas_ribbon_uri = theme.vendors.canvas_ribbon %} - {%- endif %} + {%- set canvas_ribbon_uri = theme.vendors.canvas_ribbon | default(url_for(theme.vendors._internal + '/canvas-ribbon/canvas-ribbon.js')) %} {%- endif %} diff --git a/layout/_third-party/bookmark.swig b/layout/_third-party/bookmark.swig index 332e49e1ba..655e923a80 100644 --- a/layout/_third-party/bookmark.swig +++ b/layout/_third-party/bookmark.swig @@ -1,8 +1,5 @@ {%- if theme.bookmark.enable %} - {%- set bookmark_uri = url_for(theme.vendors._internal + '/bookmark/bookmark.min.js?v=1.0') %} - {%- if theme.vendors.bookmark %} - {%- set bookmark_uri = theme.vendors.bookmark %} - {%- endif %} + {%- set bookmark_uri = theme.vendors.bookmark | default(url_for(theme.vendors._internal + '/bookmark/bookmark.min.js?v=1.0')) %} if (CONFIG.page.isPost) { diff --git a/layout/_third-party/comments/disqusjs.swig b/layout/_third-party/comments/disqusjs.swig index df0bbb6e7b..02d3b5f64b 100644 --- a/layout/_third-party/comments/disqusjs.swig +++ b/layout/_third-party/comments/disqusjs.swig @@ -1,17 +1,11 @@ {%- if page.comments %} -{%- set disqusjs_css_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css' %} -{%- if theme.vendors.disqusjs_css %} - {%- set disqusjs_css_url = theme.vendors.disqusjs_css %} -{%- endif %} - +{%- set disqusjs_css_uri = theme.vendors.disqusjs_css | default('//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqusjs.css') %} + -{%- set disqusjs_js_url = '//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js' %} -{%- if theme.vendors.disqusjs_js %} - {%- set disqusjs_js_url = theme.vendors.disqusjs_js %} -{%- endif %} +{%- set disqusjs_js_uri = theme.vendors.disqusjs_js | default('//cdn.jsdelivr.net/npm/disqusjs@1/dist/disqus.js') %} - {%- endif %} - {%- if theme.math.katex.copy_tex.copy_tex_css %} - - {%- endif %} +{%- set katex_uri = theme.vendors.katex | default('//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js') %} + +{%- if theme.math.katex.copy_tex %} + {%- set copy_tex_js_uri = theme.vendors.copy_tex_js | default('//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.js') %} + {%- set copy_tex_css_uri = theme.vendors.copy_tex_css | default('//cdn.jsdelivr.net/npm/katex@0/dist/contrib/copy-tex.min.css') %} + + {%- endif %} diff --git a/layout/_third-party/math/mathjax.swig b/layout/_third-party/math/mathjax.swig index 11d16abf7c..c7f9b915f4 100644 --- a/layout/_third-party/math/mathjax.swig +++ b/layout/_third-party/math/mathjax.swig @@ -1,6 +1,7 @@ +{%- set mhchem_uri = theme.vendors.mhchem | default('//cdn.jsdelivr.net/npm/mathjax-mhchem@3') %} +{%- set mathjax_uri = theme.vendors.mathjax | default('//cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML') %} diff --git a/layout/_third-party/quicklink.swig b/layout/_third-party/quicklink.swig index c94f474d07..4c02a3090d 100644 --- a/layout/_third-party/quicklink.swig +++ b/layout/_third-party/quicklink.swig @@ -1,8 +1,5 @@ {%- if theme.quicklink.enable %} - {%- set quicklink_uri = url_for(theme.vendors._internal + '/quicklink/quicklink.umd.js') %} - {%- if theme.vendors.quicklink %} - {%- set quicklink_uri = theme.vendors.quicklink %} - {%- endif %} + {%- set quicklink_uri = theme.vendors.quicklink | default(url_for(theme.vendors._internal + '/quicklink/quicklink.umd.js')) %} {%- if is_home() %} {%- if theme.quicklink.home %} diff --git a/layout/_third-party/search/algolia-search.swig b/layout/_third-party/search/algolia-search.swig index d1a46b4368..6f0feb89ea 100644 --- a/layout/_third-party/search/algolia-search.swig +++ b/layout/_third-party/search/algolia-search.swig @@ -1,15 +1,6 @@ -{# S: Include Algolia instantsearch.js library #} -{%- set algolia_instant_css = url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.css') %} -{%- if theme.vendors.algolia_instant_css %} - {%- set algolia_instant_css = theme.vendors.algolia_instant_css %} -{%- endif %} - - -{%- set algolia_instant_js = url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.js') %} -{%- if theme.vendors.algolia_instant_js %} - {%- set algolia_instant_js = theme.vendors.algolia_instant_js %} -{%- endif %} - -{# E: Include Algolia instantsearch.js library #} +{%- set algolia_instant_css_uri = theme.vendors.algolia_instant_css | default(url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.css')) %} +{%- set algolia_instant_js_uri = theme.vendors.algolia_instant_js | default(url_for(theme.vendors._internal + '/algolia-instant-search/instantsearch.min.js')) %} + + diff --git a/layout/_third-party/tags/mermaid.swig b/layout/_third-party/tags/mermaid.swig index c2933658e2..4f6b43bebc 100644 --- a/layout/_third-party/tags/mermaid.swig +++ b/layout/_third-party/tags/mermaid.swig @@ -1,7 +1,8 @@ {%- if theme.mermaid.enable %} +{%- set mermaid_uri = theme.vendors.mermaid | default('//cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js') %} if ($('body').find('pre.mermaid').length) { - NexT.utils.getScript('{{ theme.mermaid.cdn }}', function() { + NexT.utils.getScript('{{ mermaid_uri }}', function() { mermaid.initialize({ theme: '{{ theme.mermaid.theme }}', logLevel: 3, diff --git a/layout/_third-party/tags/pdf.swig b/layout/_third-party/tags/pdf.swig index fdb465faa3..46f5a6638d 100644 --- a/layout/_third-party/tags/pdf.swig +++ b/layout/_third-party/tags/pdf.swig @@ -1,7 +1,8 @@ {%- if theme.pdf.enable %} +{%- set pdfobject_uri = theme.vendors.pdfobject | default('//cdn.jsdelivr.net/npm/pdfobject@2/pdfobject.min.js') %} if ($('body').find('div.pdf').length) { - NexT.utils.getScript('{{ theme.pdf.pdfobject.cdn }}', function() { + NexT.utils.getScript('{{ pdfobject_uri }}', function() { $('body').find('div.pdf').each(function(i, o) { PDFObject.embed($(o).attr('target'), $(o), { pdfOpenParams: {