MCPcopy Create free account
hub / github.com/TanStack/query / verifyMarkdownLinks

Function verifyMarkdownLinks

scripts/verify-links.ts:88–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

86}
87
88async function verifyMarkdownLinks() {
89 // Find all markdown files in docs directory
90 const markdownFiles = await glob('docs/**/*.md', {
91 ignore: ['**/node_modules/**'],
92 })
93
94 console.log(`Found ${markdownFiles.length} markdown files\n`)
95
96 // Process each file
97 for (const file of markdownFiles) {
98 const content = readFileSync(file, 'utf-8')
99 const links: Array<string> = markdownLinkExtractor(content)
100
101 const relativeLinks = links.filter((link: string) => {
102 return isRelativeLink(link)
103 })
104
105 if (relativeLinks.length > 0) {
106 relativeLinks.forEach((link) => {
107 relativeLinkExists(link, file)
108 })
109 }
110 }
111
112 if (errors.length > 0) {
113 console.log(`\n❌ Found ${errors.length} broken links:`)
114 errors.forEach((err) => {
115 console.log(
116 `${err.file}\n link: ${err.link}\n resolved: ${err.resolvedPath}\n why: ${err.reason}\n`,
117 )
118 })
119 process.exit(1)
120 } else {
121 console.log('\n✅ No broken links found!')
122 }
123}
124
125verifyMarkdownLinks().catch(console.error)

Callers 1

verify-links.tsFile · 0.85

Calls 2

isRelativeLinkFunction · 0.85
relativeLinkExistsFunction · 0.85

Tested by

no test coverage detected