Skip to content

[Bug?]: Prerendering doesn't crawl all links #1954

@Brendonovich

Description

@Brendonovich

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Only some links get crawled and prerendered

Expected behavior 🤔

All available links on pages should get crawled and prerendered

Steps to reproduce 🕹

Steps:

Context 🔦

Happens because Nitro's html parser (https://github.com/natemoo-re/ultrahtml) doesn't handle un-quoted attributes properly (natemoo-re/ultrahtml#82). Workaround we'll implement is to detect prerendering and requote the data-hk attributes.

if (event.request.headers.get("x-nitro-prerender")) {
  const _html = await stream;
  const html = _html.replaceAll(/data-hk=(\d+)(?=\s|>)/g, 'data-hk="$1"');
  return html
}

Your environment 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions