You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-6Lines changed: 16 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,21 @@
2
2
3
3
An Astro integration that checks for broken links in your website during static build. It logs any broken links to the console and writes them to a file, grouping them by the document in which they occur.
4
4
5
-
## Features
5
+
## Goals
6
6
7
7
-**Checks Internal and External Links**: Validates all `<a href="...">` links found in your HTML pages.
8
8
-**Logs Broken Links**: Outputs broken link information to both the console and a log file.
9
-
-**Grouped by Document**: Broken links are grouped by the document in which they occur, making it easier to identify and fix issues.
10
-
-**Caching Mechanism**: Avoids redundant checks by caching the results of previously checked links.
11
-
-**Parallel Processing**: Checks links in parallel to improve performance.
12
-
-**Development Mode Middleware**: Checks links on each page load during development.
13
-
-**Post-Build Validation**: Scans all generated HTML files after building your site.
9
+
-**Grouped by broken URL**: To allow for quick search and replacement, a list of all pages containing the broken URL is logged.
10
+
-**Caching Mechanism**: Avoids redundant checks by caching the results of previously checked links, both internal and external, whether they are valid or not.
11
+
-**Parallel Processing**: Checks links and does IO and network operations in parallel to improve performance. We first collect all links from all pages, then only check each once, first loading the tsv cache, then saving it again when we are done. All http requests happen in parallel.
12
+
-**Local redirect awareness**: If a link is redirected in astro.config.mjs, it will be followed.
13
+
-**Timeouts and retries**: To avoid false positives, links that fail to load with ECONNRESET are retried 3 times with exponential backoff. Timeouts are set to 3 seconnd max including retries.
14
+
-**Link text preservation**: The contents of "href" are only normalized to a domain-relative path (like /foo/bar/) if they are "../relative" or "./relative" or "relative" etc. It is otherwise preserved for reportinng purposes.
15
+
-**Cross-platform compatibility**: The physical paths of the html files are normalized to domain relative paths.
16
+
-**Disk cachinng of remote links**: To speed up subsequent builds, a tab-delimied text file is optionally written to disk containing the contents of all remote links checked and the status code returned by the server, in the form URL<tab>ok/failed<tab>status code<tab>ISO-8601-formatted timestamp.
17
+
18
+
19
+
14
20
15
21
## Installation
16
22
@@ -28,6 +34,10 @@ export default defineConfig({
28
34
integrations: [
29
35
astroBrokenLinksChecker({
30
36
logFilePath:'broken-links.log', // Optional: specify the log file path
37
+
remoteLinksCacheFilePath:'remote-links-cache.tsv', // Optional: specify the path to a tab-separated file to cache remote links
38
+
maxConcurrency:10, // Optional: specify the maximum number of concurrent link checks
39
+
timeout:3000, // Optional: specify the maximum time in milliseconds for a link check to complete
40
+
cacheExpiryMinutes:30, // Optional: specify the number of minutes after which a cached externallink should be re-checked
0 commit comments