SpeculationRules.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use client';
  2. import Script from 'next/script';
  3. export function SpeculationRules() {
  4. return (
  5. <Script
  6. id="speculation-rules"
  7. type="speculationrules"
  8. dangerouslySetInnerHTML={{
  9. __html: JSON.stringify({
  10. prerender: [
  11. {
  12. where: {
  13. and: [
  14. { href_matches: '/*' },
  15. { not: { href_matches: '/customer/account/login' } },
  16. { not: { href_matches: '/checkout' } },
  17. { not: { href_matches: '/logout' } },
  18. { not: { href_matches: '/*\\?*(^|&)cart=*' } },
  19. { not: { href_matches: '/*\\?*(^|&)add-to-cart=*' } },
  20. { not: { selector_matches: '.no-prerender' } },
  21. { not: { selector_matches: '[rel~=nofollow]' } },
  22. ],
  23. },
  24. eagerness: 'moderate',
  25. },
  26. ],
  27. prefetch: [
  28. {
  29. urls: ['/'],
  30. requires: ['anonymous-client-ip-when-cross-origin'],
  31. referrer_policy: 'no-referrer',
  32. },
  33. ],
  34. }),
  35. }}
  36. />
  37. );
  38. }