Skip to content

Commit

Permalink
Merge pull request #50 from FreshP0325/patch-1
Browse files Browse the repository at this point in the history
External assets optimization for Chinese webmasters.
  • Loading branch information
mrgeneralgoo authored Jan 31, 2024
2 parents 284f610 + 438668a commit 74be388
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ class Plugin implements PluginInterface
const RADIO_VALUE_AUTO = 1;
const RADIO_VALUE_FORCE = 2;

const CDN_SOURCE_DEFAULT = 'jsDelivr';
const CDN_SOURCE_DEFAULT = 'baomitu';
const CDN_SOURCE_MERMAID = [
'jsDelivr' => 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs',
'cdnjs' => 'https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs',
'baomitu' => 'https://lib.baomitu.com/mermaid/10.7.0/mermaid.esm.min.mjs',
'bootcdn' => 'https://cdn.bootcdn.net/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs'
'baomitu' => 'https://lib.baomitu.com/mermaid/10.7.0/mermaid.esm.min.mjs'
];
const CDN_SOURCE_MATHJAX = [
'jsDelivr' => 'https://cdn.jsdelivr.net/npm/mathjax/es5/tex-mml-chtml.min.js',
'cdnjs' => 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js',
'baomitu' => 'https://lib.baomitu.com/mathjax/latest/es5/tex-mml-chtml.min.js',
'bootcdn' => 'https://cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js'
'baomitu' => 'https://lib.baomitu.com/mathjax/latest/es5/tex-mml-chtml.min.js'
];

public static function activate()
Expand Down Expand Up @@ -105,7 +103,7 @@ public static function resourceLink()

if ($isAvailableMathjax) {
$resourceContent .= '<script type="text/javascript">(function(){MathJax={tex:{inlineMath:[[\'$\',\'$\'],[\'\\\\(\',\'\\\\)\']]}}})();</script>';
$resourceContent .= '<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>';
$resourceContent .= '<script defer src="https://polyfill.alicdn.com/v3/polyfill.min.js?features=es6"></script>';
$resourceContent .= sprintf('<script id="MathJax-script" defer type="text/javascript" src="%s"></script>', self::CDN_SOURCE_MATHJAX[$configCDN] ?: self::CDN_SOURCE_MATHJAX[self::CDN_SOURCE_DEFAULT]);
}

Expand Down

0 comments on commit 74be388

Please sign in to comment.