feat: self-host KaTeX CSS (#279)

This commit is contained in:
Katsuyuki Karasawa
2025-01-13 00:10:08 +09:00
committed by saicaca
parent baa894183b
commit 081ec35b07
3 changed files with 85 additions and 63 deletions

View File

@@ -34,6 +34,7 @@
"astro-compress": "^2.3.5", "astro-compress": "^2.3.5",
"astro-icon": "^1.1.1", "astro-icon": "^1.1.1",
"hastscript": "^9.0.0", "hastscript": "^9.0.0",
"katex": "^0.16.19",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"mdast-util-to-string": "^4.0.0", "mdast-util-to-string": "^4.0.0",
"overlayscrollbars": "^2.10.0", "overlayscrollbars": "^2.10.0",

138
pnpm-lock.yaml generated
View File

@@ -65,6 +65,9 @@ importers:
hastscript: hastscript:
specifier: ^9.0.0 specifier: ^9.0.0
version: 9.0.0 version: 9.0.0
katex:
specifier: ^0.16.19
version: 0.16.19
markdown-it: markdown-it:
specifier: ^14.1.0 specifier: ^14.1.0
version: 14.1.0 version: 14.1.0
@@ -1224,80 +1227,86 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
'@parcel/watcher-android-arm64@2.4.1': '@parcel/watcher-android-arm64@2.5.0':
resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==} resolution: {integrity: sha512-qlX4eS28bUcQCdribHkg/herLe+0A9RyYC+mm2PXpncit8z5b3nSqGVzMNR3CmtAOgRutiZ02eIJJgP/b1iEFQ==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm64] cpu: [arm64]
os: [android] os: [android]
'@parcel/watcher-darwin-arm64@2.4.1': '@parcel/watcher-darwin-arm64@2.5.0':
resolution: {integrity: sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==} resolution: {integrity: sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
'@parcel/watcher-darwin-x64@2.4.1': '@parcel/watcher-darwin-x64@2.5.0':
resolution: {integrity: sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==} resolution: {integrity: sha512-9rhlwd78saKf18fT869/poydQK8YqlU26TMiNg7AIu7eBp9adqbJZqmdFOsbZ5cnLp5XvRo9wcFmNHgHdWaGYA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
'@parcel/watcher-freebsd-x64@2.4.1': '@parcel/watcher-freebsd-x64@2.5.0':
resolution: {integrity: sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==} resolution: {integrity: sha512-syvfhZzyM8kErg3VF0xpV8dixJ+RzbUaaGaeb7uDuz0D3FK97/mZ5AJQ3XNnDsXX7KkFNtyQyFrXZzQIcN49Tw==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [x64] cpu: [x64]
os: [freebsd] os: [freebsd]
'@parcel/watcher-linux-arm-glibc@2.4.1': '@parcel/watcher-linux-arm-glibc@2.5.0':
resolution: {integrity: sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==} resolution: {integrity: sha512-0VQY1K35DQET3dVYWpOaPFecqOT9dbuCfzjxoQyif1Wc574t3kOSkKevULddcR9znz1TcklCE7Ht6NIxjvTqLA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
'@parcel/watcher-linux-arm64-glibc@2.4.1': '@parcel/watcher-linux-arm-musl@2.5.0':
resolution: {integrity: sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==} resolution: {integrity: sha512-6uHywSIzz8+vi2lAzFeltnYbdHsDm3iIB57d4g5oaB9vKwjb6N6dRIgZMujw4nm5r6v9/BQH0noq6DzHrqr2pA==}
engines: {node: '>= 10.0.0'}
cpu: [arm]
os: [linux]
'@parcel/watcher-linux-arm64-glibc@2.5.0':
resolution: {integrity: sha512-BfNjXwZKxBy4WibDb/LDCriWSKLz+jJRL3cM/DllnHH5QUyoiUNEp3GmL80ZqxeumoADfCCP19+qiYiC8gUBjA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
'@parcel/watcher-linux-arm64-musl@2.4.1': '@parcel/watcher-linux-arm64-musl@2.5.0':
resolution: {integrity: sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==} resolution: {integrity: sha512-S1qARKOphxfiBEkwLUbHjCY9BWPdWnW9j7f7Hb2jPplu8UZ3nes7zpPOW9bkLbHRvWM0WDTsjdOTUgW0xLBN1Q==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
'@parcel/watcher-linux-x64-glibc@2.4.1': '@parcel/watcher-linux-x64-glibc@2.5.0':
resolution: {integrity: sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==} resolution: {integrity: sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
'@parcel/watcher-linux-x64-musl@2.4.1': '@parcel/watcher-linux-x64-musl@2.5.0':
resolution: {integrity: sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==} resolution: {integrity: sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
'@parcel/watcher-win32-arm64@2.4.1': '@parcel/watcher-win32-arm64@2.5.0':
resolution: {integrity: sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==} resolution: {integrity: sha512-twtft1d+JRNkM5YbmexfcH/N4znDtjgysFaV9zvZmmJezQsKpkfLYJ+JFV3uygugK6AtIM2oADPkB2AdhBrNig==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
'@parcel/watcher-win32-ia32@2.4.1': '@parcel/watcher-win32-ia32@2.5.0':
resolution: {integrity: sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==} resolution: {integrity: sha512-+rgpsNRKwo8A53elqbbHXdOMtY/tAtTzManTWShB5Kk54N8Q9mzNWV7tV+IbGueCbcj826MfWGU3mprWtuf1TA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
'@parcel/watcher-win32-x64@2.4.1': '@parcel/watcher-win32-x64@2.5.0':
resolution: {integrity: sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==} resolution: {integrity: sha512-lPrxve92zEHdgeff3aiu4gDOIt4u7sJYha6wbdEZDCDUhtjTsOMiaJzG5lMY4GkWH8p0fMmO2Ppq5G5XXG+DQw==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
'@parcel/watcher@2.4.1': '@parcel/watcher@2.5.0':
resolution: {integrity: sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==} resolution: {integrity: sha512-i0GV1yJnm2n3Yq1qw6QrUrd/LI9bE8WEBOTtOkpCXHHdyN3TAGgqAK/DAT05z4fq2x04cARXt2pDmjWjL92iTQ==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
'@pkgjs/parseargs@0.11.0': '@pkgjs/parseargs@0.11.0':
@@ -1970,6 +1979,10 @@ packages:
resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==} resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==}
engines: {node: '>= 14.16.0'} engines: {node: '>= 14.16.0'}
chokidar@4.0.3:
resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==}
engines: {node: '>= 14.16.0'}
chownr@2.0.0: chownr@2.0.0:
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
engines: {node: '>=10'} engines: {node: '>=10'}
@@ -2941,8 +2954,8 @@ packages:
jsonfile@6.1.0: jsonfile@6.1.0:
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
katex@0.16.11: katex@0.16.19:
resolution: {integrity: sha512-RQrI8rlHY92OLf3rho/Ts8i/XvjgguEjOkO1BEXcU3N8BqPpSzBNwV/G0Ukr+P/l3ivvJUE/Fa/CwbS6HesGNQ==} resolution: {integrity: sha512-3IA6DYVhxhBabjSLTNO9S4+OliA3Qvb8pBQXMfC4WxXJgLwZgnfDl0BmB4z6nBMdznBsZ+CGM8DrGZ5hcguDZg==}
hasBin: true hasBin: true
kind-of@6.0.3: kind-of@6.0.3:
@@ -6039,61 +6052,65 @@ snapshots:
'@pagefind/windows-x64@1.1.1': '@pagefind/windows-x64@1.1.1':
optional: true optional: true
'@parcel/watcher-android-arm64@2.4.1': '@parcel/watcher-android-arm64@2.5.0':
optional: true optional: true
'@parcel/watcher-darwin-arm64@2.4.1': '@parcel/watcher-darwin-arm64@2.5.0':
optional: true optional: true
'@parcel/watcher-darwin-x64@2.4.1': '@parcel/watcher-darwin-x64@2.5.0':
optional: true optional: true
'@parcel/watcher-freebsd-x64@2.4.1': '@parcel/watcher-freebsd-x64@2.5.0':
optional: true optional: true
'@parcel/watcher-linux-arm-glibc@2.4.1': '@parcel/watcher-linux-arm-glibc@2.5.0':
optional: true optional: true
'@parcel/watcher-linux-arm64-glibc@2.4.1': '@parcel/watcher-linux-arm-musl@2.5.0':
optional: true optional: true
'@parcel/watcher-linux-arm64-musl@2.4.1': '@parcel/watcher-linux-arm64-glibc@2.5.0':
optional: true optional: true
'@parcel/watcher-linux-x64-glibc@2.4.1': '@parcel/watcher-linux-arm64-musl@2.5.0':
optional: true optional: true
'@parcel/watcher-linux-x64-musl@2.4.1': '@parcel/watcher-linux-x64-glibc@2.5.0':
optional: true optional: true
'@parcel/watcher-win32-arm64@2.4.1': '@parcel/watcher-linux-x64-musl@2.5.0':
optional: true optional: true
'@parcel/watcher-win32-ia32@2.4.1': '@parcel/watcher-win32-arm64@2.5.0':
optional: true optional: true
'@parcel/watcher-win32-x64@2.4.1': '@parcel/watcher-win32-ia32@2.5.0':
optional: true optional: true
'@parcel/watcher@2.4.1': '@parcel/watcher-win32-x64@2.5.0':
optional: true
'@parcel/watcher@2.5.0':
dependencies: dependencies:
detect-libc: 1.0.3 detect-libc: 1.0.3
is-glob: 4.0.3 is-glob: 4.0.3
micromatch: 4.0.8 micromatch: 4.0.8
node-addon-api: 7.1.1 node-addon-api: 7.1.1
optionalDependencies: optionalDependencies:
'@parcel/watcher-android-arm64': 2.4.1 '@parcel/watcher-android-arm64': 2.5.0
'@parcel/watcher-darwin-arm64': 2.4.1 '@parcel/watcher-darwin-arm64': 2.5.0
'@parcel/watcher-darwin-x64': 2.4.1 '@parcel/watcher-darwin-x64': 2.5.0
'@parcel/watcher-freebsd-x64': 2.4.1 '@parcel/watcher-freebsd-x64': 2.5.0
'@parcel/watcher-linux-arm-glibc': 2.4.1 '@parcel/watcher-linux-arm-glibc': 2.5.0
'@parcel/watcher-linux-arm64-glibc': 2.4.1 '@parcel/watcher-linux-arm-musl': 2.5.0
'@parcel/watcher-linux-arm64-musl': 2.4.1 '@parcel/watcher-linux-arm64-glibc': 2.5.0
'@parcel/watcher-linux-x64-glibc': 2.4.1 '@parcel/watcher-linux-arm64-musl': 2.5.0
'@parcel/watcher-linux-x64-musl': 2.4.1 '@parcel/watcher-linux-x64-glibc': 2.5.0
'@parcel/watcher-win32-arm64': 2.4.1 '@parcel/watcher-linux-x64-musl': 2.5.0
'@parcel/watcher-win32-ia32': 2.4.1 '@parcel/watcher-win32-arm64': 2.5.0
'@parcel/watcher-win32-x64': 2.4.1 '@parcel/watcher-win32-ia32': 2.5.0
'@parcel/watcher-win32-x64': 2.5.0
optional: true optional: true
'@pkgjs/parseargs@0.11.0': '@pkgjs/parseargs@0.11.0':
@@ -6978,6 +6995,11 @@ snapshots:
dependencies: dependencies:
readdirp: 4.0.2 readdirp: 4.0.2
chokidar@4.0.3:
dependencies:
readdirp: 4.0.2
optional: true
chownr@2.0.0: {} chownr@2.0.0: {}
ci-info@4.0.0: {} ci-info@4.0.0: {}
@@ -8067,7 +8089,7 @@ snapshots:
optionalDependencies: optionalDependencies:
graceful-fs: 4.2.11 graceful-fs: 4.2.11
katex@0.16.11: katex@0.16.19:
dependencies: dependencies:
commander: 8.3.0 commander: 8.3.0
@@ -8519,7 +8541,7 @@ snapshots:
dependencies: dependencies:
'@types/katex': 0.16.7 '@types/katex': 0.16.7
devlop: 1.1.0 devlop: 1.1.0
katex: 0.16.11 katex: 0.16.19
micromark-factory-space: 2.0.0 micromark-factory-space: 2.0.0
micromark-util-character: 2.1.0 micromark-util-character: 2.1.0
micromark-util-symbol: 2.0.0 micromark-util-symbol: 2.0.0
@@ -9300,7 +9322,7 @@ snapshots:
'@types/katex': 0.16.7 '@types/katex': 0.16.7
hast-util-from-html-isomorphic: 2.0.0 hast-util-from-html-isomorphic: 2.0.0
hast-util-to-text: 4.0.2 hast-util-to-text: 4.0.2
katex: 0.16.11 katex: 0.16.19
unist-util-visit-parents: 6.0.1 unist-util-visit-parents: 6.0.1
vfile: 6.0.3 vfile: 6.0.3
@@ -9588,8 +9610,8 @@ snapshots:
sass@1.80.4: sass@1.80.4:
dependencies: dependencies:
'@parcel/watcher': 2.4.1 '@parcel/watcher': 2.5.0
chokidar: 4.0.1 chokidar: 4.0.3
immutable: 4.3.7 immutable: 4.3.7
source-map-js: 1.2.1 source-map-js: 1.2.1
optional: true optional: true

View File

@@ -7,17 +7,18 @@ import { profileConfig, siteConfig } from '@/config'
import ConfigCarrier from '@components/ConfigCarrier.astro' import ConfigCarrier from '@components/ConfigCarrier.astro'
import { import {
AUTO_MODE, AUTO_MODE,
DARK_MODE,
DEFAULT_THEME,
LIGHT_MODE,
BANNER_HEIGHT, BANNER_HEIGHT,
BANNER_HEIGHT_EXTEND, BANNER_HEIGHT_EXTEND,
BANNER_HEIGHT_HOME, BANNER_HEIGHT_HOME,
DARK_MODE,
DEFAULT_THEME,
LIGHT_MODE,
PAGE_WIDTH, PAGE_WIDTH,
} from '../constants/constants' } from '../constants/constants'
import { defaultFavicons } from '../constants/icon' import { defaultFavicons } from '../constants/icon'
import type { Favicon } from '../types/config' import type { Favicon } from '../types/config'
import { url, pathsEqual } from '../utils/url-utils' import { url, pathsEqual } from '../utils/url-utils'
import 'katex/dist/katex.css'
interface Props { interface Props {
title?: string title?: string
@@ -144,8 +145,6 @@ const bannerOffset =
<slot name="head"></slot> <slot name="head"></slot>
<link rel="stylesheet" href="https://cdn.staticfile.net/KaTeX/0.16.9/katex.min.css" integrity="sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV" crossorigin="anonymous">
<link rel="alternate" type="application/rss+xml" title={profileConfig.name} href={`${Astro.site}rss.xml`}/> <link rel="alternate" type="application/rss+xml" title={profileConfig.name} href={`${Astro.site}rss.xml`}/>
</head> </head>