nuxt-link-checker 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,8 +29,8 @@ Improve your sites SEO by identifying and fixing link issues in your Nuxt v3 app
29
29
 
30
30
  ## Features
31
31
 
32
- - ⛰️ Discover broken links - 404s and internal redirects
33
- - Fail on build if broken links are found (optional)
32
+ - Discover broken links - 404s and internal redirects
33
+ - 🕵️ Fail on build if broken links are found (optional)
34
34
 
35
35
  ## Install
36
36
 
@@ -92,6 +92,13 @@ export default defineNuxtConfig({
92
92
 
93
93
  ## Module Config
94
94
 
95
+ ### `failOn404`
96
+
97
+ - Type: `boolean`
98
+ - Default: `true`
99
+
100
+ If set to `true`, the build will fail if any broken links are found.
101
+
95
102
  ### `host`
96
103
 
97
104
  - Type: `string`
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "bridge": false
6
6
  },
7
7
  "configKey": "linkChecker",
8
- "version": "0.1.0"
8
+ "version": "0.1.4"
9
9
  }
package/dist/module.mjs CHANGED
@@ -71,9 +71,8 @@ const module = defineNuxtModule({
71
71
  invalidRoutes[ctx.route] = ctx.error.statusCode;
72
72
  });
73
73
  nitro.hooks.hook("close", async () => {
74
- nitro.logger.info("Scanning for broken links...");
74
+ nitro.logger.info("Scanning routes for broken links...");
75
75
  const links = Object.entries(linkMap);
76
- const hasBrokenLinks = Object.keys(invalidRoutes).length;
77
76
  let routeCount = 0;
78
77
  let badLinkCount = 0;
79
78
  links.forEach(([route, routes]) => {
@@ -85,24 +84,25 @@ const module = defineNuxtModule({
85
84
  }).filter((r) => r.statusCode !== 200 || r.badTrailingSlash);
86
85
  if (brokenLinks.length) {
87
86
  nitro.logger.log(chalk.gray(
88
- ` ${Number(++routeCount) === links.length - 1 ? "\u2514\u2500" : "\u251C\u2500"} ${route}`
87
+ ` ${Number(++routeCount) === links.length - 1 ? "\u2514\u2500" : "\u251C\u2500"} ${chalk.white(route)}`
89
88
  ));
90
89
  brokenLinks.forEach((link) => {
91
90
  badLinkCount++;
91
+ nitro.logger.log("");
92
92
  if (link.statusCode !== 200) {
93
93
  nitro.logger.log(chalk.red(
94
- ` ${link.href} ${link.statusCode}`
94
+ ` ${link.statusCode} ${link.statusCode === 404 ? "Not Found" : "Redirect"}`
95
95
  ));
96
96
  } else if (link.badTrailingSlash) {
97
97
  nitro.logger.log(chalk.yellow(
98
- ` ${link.href} Wrong trailing slash`
98
+ ` ${config.trailingSlash ? "Missing" : "Has added"} trailing slash`
99
99
  ));
100
100
  }
101
101
  nitro.logger.log(` ${chalk.gray(link.element)}`);
102
102
  });
103
103
  }
104
104
  });
105
- if (hasBrokenLinks) {
105
+ if (badLinkCount > 0) {
106
106
  nitro.logger[config.failOn404 ? "error" : "warn"](`Found ${badLinkCount} broken links.`);
107
107
  if (config.failOn404) {
108
108
  nitro.logger.log(chalk.gray('You can disable this by setting "linkChecker: { failOn404: false }" in your nuxt.config.ts.'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-link-checker",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "packageManager": "pnpm@7.18.0",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -29,9 +29,6 @@
29
29
  "@nuxt/kit": "3.0.0",
30
30
  "chalk": "^5.2.0",
31
31
  "cheerio": "1.0.0-rc.12",
32
- "defu": "^6.1.1",
33
- "radix3": "^1.0.0",
34
- "sitemap": "^7.1.1",
35
32
  "ufo": "^1.0.1"
36
33
  },
37
34
  "devDependencies": {