Skip to content

Commit

Permalink
fewg
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 22, 2024
1 parent 5dbd31c commit 0b9b50e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/build-post-list.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -161,7 +162,7 @@ function slugifyToC(str) {
}

function isDirectory(dir) {
return statSync(dir).isDirectory()
return statSync(dir).isDirectory()
}

function capitalize(text) {
Expand Down

0 comments on commit 0b9b50e

Please sign in to comment.