Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rodgtr1
Copy link
Contributor

@rodgtr1 rodgtr1 commented Aug 8, 2025

Summary

Adds link validation for React components with MDX-defined links to prevent broken links in production.

Problem

Components like Products, even though we define the links in mdx files, ultimately get rendered as part of the component and do not share the broken link checking that all other mdx files do. Need to create a new validation that works for any links in defined components.

Solution

Created server/lint-component-links.ts - a remark linter that:

  • Runs in CI/CD pipeline via existing markdown-lint workflow
  • Configurable validation with COMPONENTS_TO_CHECK and PATHS_TO_CHECK arrays
  • Handles complex paths: ./, ../, ../../ with proper version detection
  • Supports Docusaurus patterns: path.mdx, path/index.mdx, path/path.mdx
  • Dynamic version detection from config.json

Implementation

  • Integrates with .remarkrc.mjs remark pipeline
  • Uses recursive AST traversal to extract href attributes from component props
  • Validates resolved paths against filesystem
  • Provides detailed error messages with component name and broken href

Testing

Added comprehensive test suite covering path filtering, component detection, valid/broken link resolution, and folder patterns.

Copy link

github-actions bot commented Aug 8, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
travis.rodgers/lint-for-component-links 7a7e2da 4 ✅SUCCEED travis-rodgers-lint-for-component-links 2025-08-08 14:56:16

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.

1 participant