Vendor the mathjax and highlightjs code to avoid CSP loading

This commit is contained in:
Jackson Harper 2023-07-28 09:20:02 +08:00
parent 8f02871f67
commit 7d821d1c42
5 changed files with 7 additions and 20 deletions

View file

@ -1,14 +0,0 @@
type AIconProps = {
size: number
color: string
style?: React.CSSProperties
}
export function AIcon(props: AIconProps): JSX.Element {
return (
<svg style={props.style} width={props.size} height={props.size} viewBox={`0 0 20 20`} fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18.5 18L11.75 5.25L5 18" stroke={props.color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M16.5133 14.25H6.98828" stroke={props.color} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)
}

View file

@ -223,7 +223,7 @@ export function Article(props: ArticleProps): JSX.Element {
<>
<link
rel="stylesheet"
href={`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/${highlightTheme}.min.css`}
href={`/public/static/highlightjs/${highlightTheme}.min.css`}
/>
<Box
ref={articleContentRef}

View file

@ -396,11 +396,11 @@ export default function Home(): JSX.Element {
description: article?.description ?? '',
}}
>
<Script async src="/static/scripts/mathJaxConfiguration.js" />
<Script async src="/public/static/mathjax/mathJaxConfiguration.js" />
<Script
async
id="MathJax-script"
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
src="/public/static/mathjax/tex-mml-chtml.js"
/>
<Toaster />

View file

@ -29,8 +29,9 @@ export default function AppArticleEmbed(): JSX.Element {
const router = useRouter()
const [contentProps, setContentProps] =
useState<AppArticleEmbedContentProps | undefined>(undefined)
const [contentProps, setContentProps] = useState<
AppArticleEmbedContentProps | undefined
>(undefined)
useEffect(() => {
if (!router.isReady) return
@ -78,7 +79,7 @@ function AppArticleEmbedContent(
<Script
async
id="MathJax-script"
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
src="/public/static/tex-mml-chtml.js"
/>
<VStack
alignment="center"