More fixes
This commit is contained in:
parent
65c5023ae4
commit
e62fcd18d6
4 changed files with 646 additions and 7 deletions
|
@ -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 () => {
|
||||
|
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue