From 8e44b716146d3a768ef8a3d8af390e25e5c6cdfe Mon Sep 17 00:00:00 2001 From: Jayvin Hernandez Date: Fri, 3 Mar 2023 20:19:19 -0800 Subject: [PATCH] fix: fix (#310) * Muted audio by default! * Code renderin' * not but still decently standard files being viewable * reserved routes * Update validateConfig.ts --------- Co-authored-by: dicedtomato <35403473+diced@users.noreply.github.com> --- src/components/Type.tsx | 13 +++++++++---- src/lib/config/validateConfig.ts | 18 ++++++++++++++++++ src/server/routes/uploads.ts | 5 ++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/components/Type.tsx b/src/components/Type.tsx index 4271d71..1f33642 100644 --- a/src/components/Type.tsx +++ b/src/components/Type.tsx @@ -1,3 +1,4 @@ +import exts from 'lib/exts'; import { Alert, Box, @@ -55,10 +56,11 @@ export default function Type({ file, popup = false, disableMediaPreview, ...prop const [text, setText] = useState(''); const shouldRenderMarkdown = file.name.endsWith('.md'); const shouldRenderTex = file.name.endsWith('.tex'); + const shouldRenderCode: boolean = Object.keys(exts).includes(file.name.split('.').pop()); const [loading, setLoading] = useState(type === 'text' && popup); - if (type === 'text' && popup) { + if ((type === 'text' || shouldRenderMarkdown || shouldRenderTex || shouldRenderCode) && popup) { useEffect(() => { (async () => { const res = await fetch('/r/' + file.name); @@ -86,13 +88,16 @@ export default function Type({ file, popup = false, disableMediaPreview, ...prop ); }; - if ((shouldRenderMarkdown || shouldRenderTex) && !props.overrideRender && popup) + if ((shouldRenderMarkdown || shouldRenderTex || shouldRenderCode) && !props.overrideRender && popup) return ( <> {renderAlert()} {shouldRenderMarkdown && } {shouldRenderTex && } + {shouldRenderCode && !(shouldRenderTex || shouldRenderMarkdown) && ( + + )} ); @@ -115,14 +120,14 @@ export default function Type({ file, popup = false, disableMediaPreview, ...prop return popup ? ( media ? ( { - video: