* Finds the MDX doc file for a component. * Checks multiple naming conventions used in the docs/ directory: * - cometchat-{name}.mdx (e.g., cometchat-conversations.mdx) * - {name}.mdx without prefix (e.g., button.mdx, avatar.mdx) * - {name-without-cometchat}.mdx (e.g., groups.mdx for cometchat-g
(componentDirName: string)
| 115 | * - {name-without-cometchat}.mdx (e.g., groups.mdx for cometchat-groups) |
| 116 | */ |
| 117 | function findDocFile(componentDirName: string): string | null { |
| 118 | // Try exact match: cometchat-conversations.mdx |
| 119 | const exactPath = path.join(DOCS_DIR, `${componentDirName}.mdx`); |
| 120 | if (fs.existsSync(exactPath)) { |
| 121 | return exactPath; |
| 122 | } |
| 123 | |
| 124 | // Try without cometchat- prefix: conversations.mdx |
| 125 | const withoutPrefix = componentDirName.replace(/^cometchat-/, ''); |
| 126 | const shortPath = path.join(DOCS_DIR, `${withoutPrefix}.mdx`); |
| 127 | if (fs.existsSync(shortPath)) { |
| 128 | return shortPath; |
| 129 | } |
| 130 | |
| 131 | return null; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Scans docs/components/ and returns a set of all .mdx file paths. |