From 7973ebbf9dcbd6234d3ed7d72c33bce789272a92 Mon Sep 17 00:00:00 2001 From: geekifan Date: Fri, 23 May 2025 14:12:20 +0800 Subject: [PATCH] fix(mathjax): move MathJax initialization to global scope Updated MathJax initialization to be accessible globally by assigning it to the window object. This change ensures that MathJax is properly loaded and available for use across the application. Additionally, added 'defer' attribute to script tags for correct loading order. --- assets/js/mathjax.js | 28 +++++++++++++--------------- layouts/partials/js-selector.html | 4 ++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/assets/js/mathjax.js b/assets/js/mathjax.js index c5e15d5..cdec0bd 100644 --- a/assets/js/mathjax.js +++ b/assets/js/mathjax.js @@ -1,15 +1,13 @@ -document.addEventListener('DOMContentLoaded', () => { - MathJax = { - tex: { - inlineMath: [ - ['$', '$'], - ['\\(', '\\)'] - ], - displayMath: [ - ['$$', '$$'], - ['\\[', '\\]'] - ], - tags: 'ams' - } - }; -}); \ No newline at end of file +window.MathJax = { + tex: { + inlineMath: [ + ['$', '$'], + ['\\(', '\\)'] + ], + displayMath: [ + ['$$', '$$'], + ['\\[', '\\]'] + ], + tags: 'ams' + } +}; diff --git a/layouts/partials/js-selector.html b/layouts/partials/js-selector.html index 0cce980..9a7092e 100644 --- a/layouts/partials/js-selector.html +++ b/layouts/partials/js-selector.html @@ -89,9 +89,9 @@ {{ if .Params.math }} {{ $mathjaxConfig := resources.Get "js/mathjax.js" | minify | fingerprint }} - + - + {{ end }}