Another example of reading files in a mdx page

File Reader Example (File FileReader.mdx)

Files:

  • e1.json

    {
      "a": 4,
      "b": 6
    }
  • e2.json

    {
      "c": "hello",
      "d": "world!"
    }

FileReader.mdx Contents

import readFiles from '@/src/readFiles'
import { FileReader } from '@/components/FileReader'
import Styles from "@/components/UserRepos.module.css"

export default function Page({ files, fileReaderMDXContent }) {
  return (
    <div>
      <h1 className={Styles.h1}>File Reader Example (File FileReader.mdx)</h1>
      <FileReader files={files} />
      
      <h2 className={Styles.h2}>FileReader.mdx Contents</h2>
      <pre>
        {fileReaderMDXContent}
      </pre>
    </div>
  )
}

export const getStaticProps = () => readFiles("data")