refactor: self-host KaTeX assets (#6429)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
Pranab Das 2022-01-27 18:39:45 +08:00 committed by GitHub
parent f377097f0b
commit f415da1c95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 19 additions and 4 deletions

View file

@ -19,3 +19,4 @@ website/docusaurus.config.js
website/versioned_sidebars/*.json
examples/
website/static/katex/katex.min.css

View file

@ -8,3 +8,4 @@ packages/docusaurus-*/lib/*
packages/docusaurus-*/lib-next/
packages/create-docusaurus/lib/*
packages/create-docusaurus/templates/
website/static/katex/katex.min.css

View file

@ -128,6 +128,21 @@ module.exports = {
};
```
## Self-hosting KaTeX assets
Loading stylesheets, fonts, and javascript libraries from CDN sources is a good practice for popular libraries and assets. If the same assets are used across various websites, they will be cached by the browser instead of being downloaded every time we visit a new website, reducing network load. In case you prefer to self-host the `katex.min.css` (along with required KaTeX fonts), you can download the latest version from [KaTeX GitHub releases](https://github.com/KaTeX/KaTeX/releases), extract and copy `katex.min.css` and `fonts` directory (only `.woff2` font types should be enough) to your site's `static` directory, and in `docusaurus.config.js`, replace the stylesheet's `href` from the CDN url to your local path (say, `/katex/katex.min.css`).
```js title="docusaurus.config.js"
module.exports = {
stylesheets: [
{
href: '/katex/katex.min.css',
type: 'text/css',
},
],
};
```
## Upgrading rehype-katex beyond recommended version
:::tip

View file

@ -73,11 +73,8 @@ const config = {
trailingSlash: isDeployPreview,
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/katex.min.css',
href: '/katex/katex.min.css',
type: 'text/css',
integrity:
'sha384-MlJdn/WNKDGXveldHDdyRP1R4CTHr3FeuDNfhsLPYrq2t0UBkUdK2jyTnXPEK1NQ',
crossorigin: 'anonymous',
},
],
i18n: {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
website/static/katex/katex.min.css vendored Normal file

File diff suppressed because one or more lines are too long