Skip to content

Commit

Permalink
using posix
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 18, 2024
1 parent ad8e114 commit da6c058
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/build-post-list.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const { readdirSync, statSync, existsSync, readFileSync, writeFileSync } = require('fs')
const { resolve, basename, join, sep } = require('path')
const { basename, join, sep } = require('path')
const frontMatter = require('gray-matter')
const toc = require('markdown-toc')
const { slugify } = require('markdown-toc/lib/utils')
const readingTime = require('reading-time')
const { markdownToTxt } = require('markdown-to-txt')
const { buildNavTree, addDocButtons } = require('./build-docs')
const path = require('path');

let specWeight = 100
const result = {
Expand Down Expand Up @@ -54,7 +55,7 @@ function walkDirectories(directories, result, basePath, sectionWeight = 0, secti
let details
const fileName = join(directory, file)
const fileNameWithSection = join(fileName, '_section.mdx')
const slug = fileName.replace(new RegExp(`^${basePath.replace(/\\/g, sep).replace(/\//g, sep)}`), '').replace(/\\/g, '/'); // Normalize slugs to use `/`
const slug = fileName.replace(new RegExp(`^${basePath.replace(/\\/g, sep).replace(/\//g, sep)}`), '').split(sep).join('/'); // Normalize slugs using posix-style paths
const slugElements = slug.split('/');

if (isDirectory(fileName)) {
Expand Down Expand Up @@ -96,7 +97,7 @@ function walkDirectories(directories, result, basePath, sectionWeight = 0, secti
details.rootSectionId = rootSectionId
details.id = fileName
details.isIndex = fileName.endsWith(join(sep, 'index.mdx')) // Platform-independent index check
details.slug = details.isIndex ? sectionSlug : slug.replace(/\.mdx$/, '')
details.slug = details.isIndex ? sectionSlug : path.posix.join(slug.replace(/\.mdx$/, ''));
if (details.slug.includes('/reference/specification/') && !details.title) {
const fileBaseName = basename(data.slug) // ex. v2.0.0 | v2.1.0-next-spec.1
const fileName = fileBaseName.split('-')[0] // v2.0.0 | v2.1.0
Expand Down

0 comments on commit da6c058

Please sign in to comment.