diff --git a/src/lib/exts.ts b/src/lib/exts.ts index d581b24..2326463 100644 --- a/src/lib/exts.ts +++ b/src/lib/exts.ts @@ -15,7 +15,7 @@ export default { yaml: 'YAML', c: 'C', cpp: 'C++', - csharp: 'C#', + cs: 'C#', go: 'Go', docker: 'Docker', toml: 'TOML', @@ -40,7 +40,6 @@ export default { export const extToPrismComponent = (ext: string) => { // await import(prismjs/components/prism-${extToPrismComponent(ext)}.js) - return { md: 'markdown', css: 'css', @@ -57,7 +56,7 @@ export const extToPrismComponent = (ext: string) => { yaml: 'yaml', c: 'c', cpp: 'cpp', - csharp: 'csharp', + cs: 'csharp', go: 'go', docker: 'docker', toml: 'toml', diff --git a/src/pages/view/[id].tsx b/src/pages/view/[id].tsx index b3e99bf..4d9f0ff 100644 --- a/src/pages/view/[id].tsx +++ b/src/pages/view/[id].tsx @@ -1,13 +1,26 @@ import { Box, Button, Modal, PasswordInput } from '@mantine/core'; +import type { Image } from '@prisma/client'; +import Link from 'components/Link'; import exts from 'lib/exts'; import prisma from 'lib/prisma'; import { parseString } from 'lib/utils/parser'; +import type { UserExtended } from 'middleware/withZipline'; import { GetServerSideProps } from 'next'; import Head from 'next/head'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; -export default function EmbeddedFile({ image, user, pass, prismRender }) { +export default function EmbeddedFile({ + image, + user, + pass, + prismRender, +}: { + image: Image; + user: UserExtended; + pass: boolean; + prismRender: boolean; +}) { const dataURL = (route: string) => `${route}/${image.file}`; const router = useRouter(); @@ -16,7 +29,7 @@ export default function EmbeddedFile({ image, user, pass, prismRender }) { const [error, setError] = useState(''); // reapply date from workaround - image.created_at = new Date(image?.created_at); + image.created_at = new Date(image ? image.created_at : 0); const check = async () => { const res = await fetch(`/api/auth/image?id=${image.id}&password=${password}`); @@ -71,7 +84,7 @@ export default function EmbeddedFile({ image, user, pass, prismRender }) { {user.embedTitle && ( )} - + > )} {image.mimetype.startsWith('image') && ( @@ -98,6 +111,9 @@ export default function EmbeddedFile({ image, user, pass, prismRender }) { > )} + {!image.mimetype.startsWith('video') && !image.mimetype.startsWith('image') && ( + + )}