From fb103bb1479285e4633a23bb8dd32dbc4ca14720 Mon Sep 17 00:00:00 2001 From: Thomas Mathew Date: Sun, 28 Apr 2019 17:29:49 -0700 Subject: [PATCH] Include extensions mhchem & copy-tex in home-page (#1932) * Include extensions mhchem & copy-tex in website home-page * Use relative link to mhchem and copy-tex - Included relative links extensions mhchem & copy-tex in website/pages/index.html - Included copy commands in website/lib/build.js. Will be used in 'yarn build' - Included 2 more files in .gitignore * Correct CDN path of extensions * tweak grammar and alignment of a comment --- .gitignore | 2 ++ website/lib/build.js | 9 +++++++++ website/pages/index.html | 3 +++ 3 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index b073caed..3e4dfeb3 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ website/node_modules website/i18n/* website/static/static/katex.* website/static/static/fonts +website/static/static/copy-tex.* +website/static/static/mhchem.* diff --git a/website/lib/build.js b/website/lib/build.js index 3366edfc..1b6482e0 100644 --- a/website/lib/build.js +++ b/website/lib/build.js @@ -16,11 +16,20 @@ fs.copySync('../dist/katex.min.js', 'static/static/katex.min.js'); fs.copySync('../dist/katex.min.css', 'static/static/katex.min.css'); fs.copySync('../dist/fonts', 'static/static/fonts'); +// copy local built KaTeX extensions +fs.copySync('../dist/contrib/copy-tex.min.css', 'static/static/copy-tex.min.css'); +fs.copySync('../dist/contrib/copy-tex.min.js', 'static/static/copy-tex.min.js'); +fs.copySync('../dist/contrib/mhchem.min.js', 'static/static/mhchem.min.js'); + + // use KaTeX from CDN on the main page for Netlify production deploy if (process.env.CONTEXT === 'production') { const version = require('../versions.json')[0]; let indexHtml = fs.readFileSync('pages/index.html', 'utf8'); indexHtml = indexHtml.replace(/(["'])static\/(katex|fonts)/g, `$1https://cdn.jsdelivr.net/npm/katex@${version}/dist/$2`); + // the CDN pathway is different for `copy-tex` and `mhchem` + indexHtml = indexHtml.replace(/(["'])static\/(copy-tex|mhchem)/g, + `$1https://cdn.jsdelivr.net/npm/katex@${version}/dist/contrib/$2`); fs.writeFileSync('pages/index.html', indexHtml); } diff --git a/website/pages/index.html b/website/pages/index.html index 73bdf9c8..13c39ee3 100644 --- a/website/pages/index.html +++ b/website/pages/index.html @@ -24,9 +24,12 @@ + + +