%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/src/components/ui/
Upload File :
Create Path :
Current File : /home2/rezakur1/ai.rezakurnia.com/zh-router-frontend/src/components/ui/MarkdownInner.tsx

import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";

const components = {
  p: ({ children }: any) => (
    <p className="mb-3 text-sm leading-relaxed text-slate-100 last:mb-0">
      {children}
    </p>
  ),
  strong: ({ children }: any) => (
    <strong className="font-semibold text-white">{children}</strong>
  ),
  em: ({ children }: any) => <em className="text-slate-200">{children}</em>,
  code: (props: any) => {
    // Blok kode vs inline code dibedakan dari `inline` dari react-markdown
    if (props.inline) {
      return (
        <code className="rounded-md border border-white/[0.08] bg-white/[0.06] px-1.5 py-0.5 font-mono text-[12px] text-blue-200">
          {props.children}
        </code>
      );
    }
    return (
      <code className="block overflow-x-auto rounded-xl border border-white/[0.06] bg-ink-900 px-4 py-3 font-mono text-[12.5px] leading-relaxed text-slate-200">
        {props.children}
      </code>
    );
  },
  pre: ({ children }: any) => (
    <div className="my-3 overflow-hidden rounded-xl border border-white/[0.06] bg-ink-900">
      {children}
    </div>
  ),
  h1: ({ children }: any) => (
    <h1 className="mb-2 text-lg font-bold text-white">{children}</h1>
  ),
  h2: ({ children }: any) => (
    <h2 className="mb-2 text-base font-bold text-white">{children}</h2>
  ),
  h3: ({ children }: any) => (
    <h3 className="mb-1.5 text-sm font-semibold text-white">{children}</h3>
  ),
  h4: ({ children }: any) => (
    <h4 className="mb-1.5 text-sm font-semibold text-white">{children}</h4>
  ),
  ul: ({ children }: any) => (
    <ul className="mb-3 list-disc space-y-1 pl-5 marker:text-blue-400 last:mb-0">
      {children}
    </ul>
  ),
  ol: ({ children }: any) => (
    <ol className="mb-3 list-decimal space-y-1 pl-5 marker:text-blue-400 last:mb-0">
      {children}
    </ol>
  ),
  li: ({ children }: any) => (
    <li className="text-sm leading-relaxed text-slate-100">{children}</li>
  ),
  blockquote: ({ children }: any) => (
    <blockquote className="my-3 border-l-2 border-blue-400/60 bg-white/[0.02] py-2 pl-4 pr-3 text-sm text-slate-300">
      {children}
    </blockquote>
  ),
  a: ({ href, children }: any) => (
    <a
      href={href}
      target="_blank"
      rel="noreferrer noopener"
      className="font-medium text-blue-300 underline decoration-blue-400/40 underline-offset-2 hover:text-blue-200"
    >
      {children}
    </a>
  ),
  hr: () => (
    <hr className="my-4 border-t border-white/[0.08]" />
  ),
  table: ({ children }: any) => (
    <div className="my-3 overflow-x-auto rounded-xl border border-white/[0.06]">
      <table className="w-full text-left text-xs">{children}</table>
    </div>
  ),
  thead: ({ children }: any) => (
    <thead className="border-b border-white/[0.08] bg-white/[0.03]">
      {children}
    </thead>
  ),
  th: ({ children }: any) => (
    <th className="px-3.5 py-2.5 font-semibold text-slate-200">
      {children}
    </th>
  ),
  td: ({ children }: any) => (
    <td className="border-t border-white/[0.05] px-3.5 py-2.5 text-slate-300">
      {children}
    </td>
  ),
};

export default function MarkdownInner({ content }: { content: string }) {
  return (
    <div className="text-sm">
      <ReactMarkdown remarkPlugins={[remarkGfm]} components={components}>
        {content}
      </ReactMarkdown>
    </div>
  );
}

Zerion Mini Shell 1.0