Skip to content

Conversation

@frano-m
Copy link
Contributor

@frano-m frano-m commented Oct 28, 2025

Closes #688.

This pull request introduces new utilities for working with MDX files in the documentation system and provides a helper for generating Next.js static paths for MDX pages. The main changes add functions to recursively map MDX file paths to slugs, resolve absolute directories from relative segments, and build static paths for static site generation.

MDX file mapping and path utilities

  • Added mapMDXSlugByFilePaths in src/utils/mdx/files/mapMDXSlugByFilePaths.ts to recursively scan directories for .mdx files and map each file path to its slug, which is derived from its relative directory segments and filename.
  • Added resolveRelativeDirs in src/utils/mdx/files/resolveRelativeDirs.ts to construct an absolute path from an array of directory segments relative to the docs root.

Static site generation support

  • Added buildStaticPaths in src/utils/mdx/staticGeneration/staticPaths.ts to generate Next.js-compatible static paths for all MDX files found under specified relative directories, using the slug mapping utility.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds utilities for generating Next.js static paths from MDX documentation files. The implementation provides a clean abstraction for scanning directories, mapping MDX files to slugs, and building static paths for static site generation.

Key Changes:

  • New utility to recursively scan directories and map MDX file paths to URL slugs based on their location and filename
  • Helper function to resolve absolute paths from relative directory segments
  • Main function to generate Next.js-compatible static paths for all discovered MDX files

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/utils/mdx/staticGeneration/staticPaths.ts Exports main helper that orchestrates MDX discovery and static path generation
src/utils/mdx/files/resolveRelativeDirs.ts Provides path resolution from relative directory segments to absolute paths
src/utils/mdx/files/mapMDXSlugByFilePaths.ts Implements recursive directory scanning and slug mapping for MDX files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@frano-m frano-m force-pushed the fran/688-staticpaths branch from af1dbaf to 2e2696a Compare October 28, 2025 04:22
@frano-m frano-m changed the title feat: add get static paths helper function (#688) feat!: add get static paths helper function (#688) Oct 28, 2025
@NoopDog NoopDog merged commit 887b1d8 into main Oct 28, 2025
2 checks passed
@frano-m frano-m deleted the fran/688-staticpaths branch November 3, 2025 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add get static paths helper function

3 participants