Skip to content

Commit bd59666

Browse files
committed
fix(html-validator): skip /_og/ prerender routes
nuxt-og-image signs OG URLs like /_og/s/o_*.png under strict mode. The intermediate HTML render Nitro hands to prerender:generate has a .html fileName, so @nuxtjs/html-validator validates it against all rules, including long-title, which fails because the OG page inherits the source page's full title (routinely >70 chars). The module's `ignore` option is dev-mode only — there's no prod hook to opt out, so patch the check at module.mjs:98 to early-return for routes starting with /_og/.
1 parent 37b2883 commit bd59666

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/dist/module.mjs b/dist/module.mjs
2+
index 0000000..0000001 100644
3+
--- a/dist/module.mjs
4+
+++ b/dist/module.mjs
5+
@@ -95,7 +95,7 @@ const module = defineNuxtModule({
6+
}
7+
nuxt.hook("nitro:init", (nitro) => {
8+
nitro.hooks.hook("prerender:generate", (route) => {
9+
- if (!route.contents || !route.fileName?.endsWith(".html")) {
10+
+ if (!route.contents || !route.fileName?.endsWith(".html") || route.route?.startsWith("/_og/")) {
11+
return;
12+
}
13+
if (route.contents.match(NuxtRedirectHtmlRegex)) {

pnpm-lock.yaml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ packageExtensions:
4545
patchedDependencies:
4646
'@jsr/deno__doc@0.189.1': patches/@jsr__deno__doc@0.189.1.patch
4747
'@nuxt/test-utils': patches/@nuxt__test-utils.patch
48+
'@nuxtjs/html-validator': patches/@nuxtjs__html-validator.patch
4849

4950
savePrefix: ''
5051

0 commit comments

Comments
 (0)