forked from dair-ai/Prompt-Engineering-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentFileNames.tsx
More file actions
31 lines (27 loc) · 854 Bytes
/
ContentFileNames.tsx
File metadata and controls
31 lines (27 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// components/ContentFileNames.tsx
import React, { useEffect, useState } from 'react';
import { Cards, Card } from 'nextra-theme-docs';
import { FilesIcon } from './icons';
const ContentFileNames = ({ section = 'research', lang = 'en' }) => {
const [fileNames, setFileNames] = useState([]);
useEffect(() => {
fetch(`/api/contentFiles?section=${section}&lang=${lang}`)
.then(response => response.json())
.then(data => setFileNames(data.fileNames));
}, [section, lang]);
return (
<Cards>
{fileNames.map(({ slug, title }, index) => (
<React.Fragment key={index}>
<Card
icon={<FilesIcon />}
title={title}
href={`/${section}/${slug}`}
children={<></>}
/>
</React.Fragment>
))}
</Cards>
);
};
export default ContentFileNames;