mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
refactor: self-host KaTeX assets (#6429)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
f377097f0b
commit
f415da1c95
25 changed files with 19 additions and 4 deletions
|
@ -19,3 +19,4 @@ website/docusaurus.config.js
|
|||
website/versioned_sidebars/*.json
|
||||
|
||||
examples/
|
||||
website/static/katex/katex.min.css
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: {
|
||||
|
|
BIN
website/static/katex/fonts/KaTeX_AMS-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_AMS-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Caligraphic-Bold.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Caligraphic-Bold.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Caligraphic-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Caligraphic-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Fraktur-Bold.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Fraktur-Bold.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Fraktur-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Fraktur-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Main-Bold.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Main-Bold.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Main-BoldItalic.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Main-BoldItalic.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Main-Italic.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Main-Italic.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Main-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Main-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Math-BoldItalic.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Math-BoldItalic.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Math-Italic.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Math-Italic.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_SansSerif-Bold.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_SansSerif-Bold.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_SansSerif-Italic.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_SansSerif-Italic.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_SansSerif-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_SansSerif-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Script-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Script-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Size1-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Size1-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Size2-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Size2-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Size3-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Size3-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Size4-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Size4-Regular.woff2
Normal file
Binary file not shown.
BIN
website/static/katex/fonts/KaTeX_Typewriter-Regular.woff2
Normal file
BIN
website/static/katex/fonts/KaTeX_Typewriter-Regular.woff2
Normal file
Binary file not shown.
1
website/static/katex/katex.min.css
vendored
Normal file
1
website/static/katex/katex.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue