From 0b9b50e8514117f89fabefe8423da6904e7197ce Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Tue, 22 Oct 2024 19:22:27 +0530 Subject: [PATCH] fewg --- scripts/build-post-list.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/build-post-list.js b/scripts/build-post-list.js index e9a95a6c4488..0f54ecea0051 100644 --- a/scripts/build-post-list.js +++ b/scripts/build-post-list.js @@ -1,5 +1,5 @@ const { readdirSync, statSync, existsSync, readFileSync, writeFileSync } = require('fs') -const { basename } = require('path') +const { basename, join } = require('path') const frontMatter = require('gray-matter') const toc = require('markdown-toc') const { slugify } = require('markdown-toc/lib/utils') @@ -60,10 +60,11 @@ function walkDirectories(directories, result, basePath, sectionWeight = 0, secti for (let file of files) { let details - const fileName = [directory, file].join('/') - const fileNameWithSection = [fileName, '_section.mdx'].join('/') - const slug = fileName.replace(new RegExp(`^${basePath}`), '') + const fileName = join(directory, file); + const fileNameWithSection = join(fileName, '_section.mdx'); + const slug = fileName.replace(new RegExp(`^${basePath}`), '').replace(/\\/g, '/'); const slugElements = slug.split('/'); + if (isDirectory(fileName)) { if (existsSync(fileNameWithSection)) { // Passing a second argument to frontMatter disables cache. See https://github.com/asyncapi/website/issues/1057 @@ -161,7 +162,7 @@ function slugifyToC(str) { } function isDirectory(dir) { - return statSync(dir).isDirectory() + return statSync(dir).isDirectory() } function capitalize(text) {