2024-01-15 12:33:15 +00:00
|
|
|
import { nicelog } from '@/utils/nicelog'
|
2024-02-29 16:28:45 +00:00
|
|
|
import { check } from 'linkinator'
|
2024-01-15 12:33:15 +00:00
|
|
|
|
|
|
|
export async function checkBrokenLinks() {
|
2024-02-29 16:28:45 +00:00
|
|
|
const results = await check({
|
|
|
|
path: 'http://localhost:3001',
|
|
|
|
recurse: true,
|
|
|
|
})
|
|
|
|
|
|
|
|
// All good
|
|
|
|
if (results.passed) return
|
|
|
|
|
|
|
|
// There seems to be a porblem
|
|
|
|
nicelog(
|
|
|
|
`𐄂 Broken links detected!\n\n` +
|
|
|
|
results.links
|
|
|
|
.filter((result) => result.state !== 'OK')
|
|
|
|
.map(
|
|
|
|
(result, i) =>
|
|
|
|
`${i + 1}.\t${result.url}\n\tFrom: ${result.parent}\n\tStatus: ${result.status}`
|
|
|
|
)
|
|
|
|
.join('\n\n') +
|
|
|
|
'\n\n'
|
2024-01-15 12:33:15 +00:00
|
|
|
)
|
|
|
|
}
|