import { useState } from 'react'; import { useQuery } from '@tanstack/react-query'; import { useTranslation } from 'react-i18next'; import { ChevronDown, ChevronUp, FileText } from 'lucide-react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { api } from '../api/client'; interface FolderReadmePanelProps { folderId: number; } /** * Side panel that renders a `.md` file from the selected folder (#1268). * Hidden when the folder has no markdown file. Disables raw HTML and links * stay text-only — same posture as the print-archive note panel. */ export function FolderReadmePanel({ folderId }: FolderReadmePanelProps) { const { t } = useTranslation(); const [collapsed, setCollapsed] = useState(false); const { data, isLoading, error } = useQuery({ queryKey: ['folder-readme', folderId], queryFn: () => api.getLibraryFolderReadme(folderId), retry: false, staleTime: 30_000, }); if (isLoading || error || !data) return null; return (
{children}
, ul: ({ children }) =>{children}
) : (
{children}
);
},
pre: ({ children }) => {children},
blockquote: ({ children }) => (
{children}), a: ({ children, href }) => ( {children} ), table: ({ children }) => (