Skip to content

Commit 2b6dca4

Browse files
authored
Update index.js
Adding an additional filter for valid md files only while pre-rendering
1 parent 70a3d16 commit 2b6dca4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/crawler/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ function getPreview(data) {
3535

3636
function getFolders(source) {
3737
const isDirectory = source => fs.lstatSync(source).isDirectory();
38-
const isFile = source => !fs.lstatSync(source).isDirectory();
38+
const isAValidFile = source => !fs.lstatSync(source).isDirectory() && source.endsWith('.md');
3939
const getAllListings = source =>
4040
fs.readdirSync(source).map(name => join(source, name));
4141
let allContent = getAllListings(source);
42-
const edges = allContent.filter(isFile).map(file => {
42+
const edges = allContent.filter(isAValidFile).map(file => {
4343
const data = fs.readFileSync(file, 'utf-8');
4444
const id = file.substr(file.lastIndexOf(sep) + 1);
4545
const format = getExtensionFromFilename(id);

0 commit comments

Comments
 (0)