CMSgov / design-system

Open source design and front-end development resources for creating Section 508 compliant, responsive, and consistent websites.
https://design.cms.gov
Other
312 stars 85 forks source link

[WNMGDS-2855] Markdown and MDX broken link script #3185

Closed jack-ryan-nava-pbc closed 1 month ago

jack-ryan-nava-pbc commented 1 month ago

Summary

Ticket

The goal of this script is to provide a relatively quick way to check for outdated links and content within the codebase. If a file/url combo is listed in the output file, the idea is that it needs to be checked because the URL did not return a 200 status code.

I've added a new script that can be run via an npm script. The goal of this script is to check all links that begin with http or https located within our .md or .mdx files throughout the codebase. I've tried to exclude known directories that we don't want to dig through, like node_modules. If there are others that should be excluded, please let me know.

I'm currently writing to a .txt file. I'm meh about this and am not sure what format might be the easiest for folks to parse and work with when reviewing content. I'm also open to discussing the formatting of the content within the file, as that might not be the easiest to parse.

How to test

  1. Run yarn lint:links
  2. Confirm that the content brokenLinkReport.txt is overwritten with a series of filenames, urls and HTTP response codes.

Checklist

Screenshot

Screenshot 2024-08-07 at 7 54 39 PM