More fixes

This commit is contained in:
Gnarwhal 2024-09-19 22:21:59 +00:00
parent 65c5023ae4
commit e62fcd18d6
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
4 changed files with 646 additions and 7 deletions

View file

@ -4,7 +4,7 @@ import { useState } from 'react';
import * as style from './copy.css';
export default function Copy({ className, text, children }: { className?: string, text: string, children: React.ReactNode }) {
export default function Copy({ className, text, children }: { className?: string, text: string, children?: React.ReactNode }) {
const [copied, set_copied ] = useState(false);
function make_copy_text(text: string) {
return () => {

View file

@ -10,11 +10,11 @@ export default function MarkdownContent({ text }: { text: string }) {
<Markdown
components={{
'code': (props) => {
const split = props.className.split('-');
const split = props.className?.split('-') ?? ['none'];
return (
<div className={style.code_bounds}>
<Copy className={style.copy} text={props.children}></Copy>
<Text language={split.length == 0 ? 'none' : map_to_type(split[split.length - 1])} text={props.children} line_numbers={false} />
<Copy className={style.copy} text={props.children as string}></Copy>
<Text language={split.length == 0 ? 'none' : map_to_type(split[split.length - 1])} text={props.children as string} line_numbers={false} />
</div>
);
}

View file

@ -41,7 +41,7 @@ const type_map = {
export function map_to_type(extension?: string) {
if (extension != undefined) {
return type_map[extension as keyof typeof languages] ?? 'none';
return type_map[extension as keyof typeof type_map] ?? 'none';
} else {
return 'none';
}