()
| 87 | } |
| 88 | |
| 89 | const generateDocsContent = async () => { |
| 90 | try { |
| 91 | const files = fs.readdirSync(`${DOCS_BASE_URL}`); |
| 92 | const docs = []; |
| 93 | |
| 94 | const sections = files.filter(file => file !== '.DS_Store'); |
| 95 | |
| 96 | for (const section of sections) { |
| 97 | if (section.includes('docs.json')) continue; |
| 98 | |
| 99 | const filesInSection = fs.readdirSync( |
| 100 | `${DOCS_BASE_URL}/${section}` |
| 101 | ); |
| 102 | |
| 103 | for (const file of filesInSection) { |
| 104 | if (file.includes('.DS_Store')) continue; |
| 105 | |
| 106 | const slug = file.replace('.mdx', ''); |
| 107 | const { frontmatter, content } = await fetchMDXContent({ |
| 108 | slug, |
| 109 | section, |
| 110 | dirPath: DOCS_BASE_URL, |
| 111 | baseUrl: `${BASE_URL}/docs` |
| 112 | }); |
| 113 | |
| 114 | docs.push({ |
| 115 | slug, |
| 116 | section, |
| 117 | content, |
| 118 | frontmatter |
| 119 | }); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | await fs.promises.writeFile( |
| 124 | `${DOCS_BASE_URL}/docs.json`, |
| 125 | JSON.stringify(docs) |
| 126 | ); |
| 127 | } catch (error) { |
| 128 | console.error(error); |
| 129 | process.exit(1); |
| 130 | } |
| 131 | }; |
| 132 | |
| 133 | const generateLearnContent = async () => { |
| 134 | try { |
no test coverage detected