// components/PromptFiles.js import React, { useEffect, useState } from 'react'; import { Cards, Card } from 'nextra-theme-docs'; import { FilesIcon } from './icons'; // Ensure this path is correct for your project const PromptFiles = ({ lang = 'en' }) => { const [promptsData, setPromptsData] = useState([]); useEffect(() => { // Fetch the data from the API fetch(`/api/promptsFiles?lang=${lang}`) .then((response) => response.json()) .then((data) => { // Assuming the API returns data structured as an array of objects setPromptsData(data); }) .catch((error) => { console.error('Error fetching prompt files:', error); }); }, [lang]); return (
{promptsData.map(({ folderKey, folderName, files }) => (


{folderName}

{files.map(({ slug, title }) => ( } // This should be the icon component you want to use title={title} href={`/prompts/${folderKey}/${slug}`} // Adjust the href to match your routing pattern > {/* Additional content for each card, if any, goes here */} ))}
))}
); }; export default PromptFiles;