Files
medusa-store/www/packages/build-scripts/src/retrieve-mdx-pages.ts
Shahed Nasser d1a1135328 docs: migrate UI docs (#13245)
* docs: create a new UI docs project (#13233)

* docs: create a new UI docs project

* fix installation errors

* docs: migrate UI docs content to new project (#13241)

* Fix content

* added examples for some components

* finish adding examples

* lint fix

* fix build errors

* delete empty files

* path fixes + refactor

* fix build error
2025-08-20 11:42:25 +03:00

41 lines
930 B
TypeScript

import { readdirSync } from "fs"
import path from "path"
import { getFileSlugSync } from "docs-utils"
type Options = {
basePath: string
}
export function retrieveMdxPages({ basePath }: Options): string[] {
function retrieveMdxFilesInPath(dir: string): string[] {
const urls = []
const files = readdirSync(dir, {
withFileTypes: true,
})
for (const file of files) {
const filePath = path.join(dir, file.name)
if (file.isDirectory()) {
if (!file.name.startsWith("_")) {
urls.push(...retrieveMdxFilesInPath(filePath))
}
continue
} else if (file.name !== "page.mdx") {
continue
}
const slug = getFileSlugSync(filePath)
const url = (slug || filePath.replace(basePath, ""))
.replace(file.name, "")
.replace(/\/$/, "")
urls.push(url)
}
return urls
}
return retrieveMdxFilesInPath(basePath)
}