'use client'; import { useState } from 'react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import type { RecipeSection } from '@/lib/parseRecipe'; interface RecipeTabsProps { sections: RecipeSection[]; folderPath: string; } export default function RecipeTabs({ sections, folderPath }: RecipeTabsProps) { const tabOrder = ['Photos', 'Ingredients', 'Instructions', 'Notes', 'References']; const orderedSections = tabOrder .map(tabName => sections.find(s => s.title === tabName)) .filter((s): s is RecipeSection => s !== undefined); const [activeTab, setActiveTab] = useState(orderedSections[0]?.title || ''); if (orderedSections.length === 0) { return null; } const activeSection = orderedSections.find(s => s.title === activeTab); return (
- let ReactMarkdown handle it to avoid hydration errors
code: ({ inline, children, ...props }: any) => {
if (inline) {
return (
{children}
);
}
return (
{children}
);
},
}}
>
{activeSection.content}