mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-03 20:27:20 +02:00
23 lines
540 B
JavaScript
23 lines
540 B
JavaScript
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
const globby = require('globby');
|
|
const {encodePath, fileToPath} = require('./utils');
|
|
|
|
async function loadPages(pagesDir) {
|
|
const pagesFiles = await globby(['**/*.js'], {
|
|
cwd: pagesDir
|
|
});
|
|
|
|
const pagesData = await Promise.all(
|
|
pagesFiles.map(async source => {
|
|
const filepath = path.resolve(pagesDir, source);
|
|
return {
|
|
path: encodePath(fileToPath(source)),
|
|
source
|
|
};
|
|
})
|
|
);
|
|
return pagesData;
|
|
}
|
|
|
|
module.exports = loadPages;
|