Skip to content

Commit 2fa8e91

Browse files
committed
fix: parse files under directories
1 parent 3a9f2e5 commit 2fa8e91

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ const components = fs.readFileSync(path.join(__dirname, '../src/index.js'))
1515
.split('\n')
1616
.map(line => line.split(' ').pop().replace(/('|;)/g, ''))
1717
.filter(line => line.startsWith('./components/'))
18-
.map(line => require.resolve(path.join(__dirname, '../src', line)));
18+
.map(line => {
19+
const file = require.resolve(path.join(__dirname, '../src', line));
20+
if (file.endsWith('/index.js')) {
21+
const matches = fs.readFileSync(file).toString().match(/export \{ default as default \} from .+/);
22+
if (matches && matches.length) {
23+
const name = matches[0].split(' ').pop().replace(/('|;)/g, '');
24+
return require.resolve(path.join(__dirname, '../src', line, name));
25+
}
26+
}
27+
return file;
28+
});
1929

2030
const items = [];
2131
const index = [];

0 commit comments

Comments
 (0)