1
- import React , { lazy , Suspense } from "react"
1
+ import React , { lazy , Suspense , useEffect } from "react"
2
2
import Header from "./header"
3
3
import ThemeProvider from "../context/themeContext"
4
4
import Footer from "./Footer/Footer"
5
5
import "./layout.scss"
6
6
import PropTypes from "prop-types"
7
7
import "./FontAwesomeOne/FontAwesomeOne"
8
+ import { Helmet } from "react-helmet"
9
+ import { useStaticQuery , graphql } from "gatsby"
8
10
9
11
const BannerRedirect = lazy ( ( ) => import ( "./BannerRedirect/BannerRedirect" ) )
10
12
@@ -16,7 +18,7 @@ const Layout = ({ children, options = {}, location }) => {
16
18
17
19
options = { ...defaultOptions , ...options }
18
20
19
- React . useEffect ( ( ) => {
21
+ useEffect ( ( ) => {
20
22
const hash = location ?. state ?. component
21
23
let el = hash && document . getElementById ( hash )
22
24
if ( el ) {
@@ -27,17 +29,50 @@ const Layout = ({ children, options = {}, location }) => {
27
29
const userLanguage =
28
30
typeof window !== "undefined" ? navigator . language : undefined
29
31
32
+ const { allStrapiHome } = useStaticQuery ( graphql `
33
+ query PreloadDynamicHero {
34
+ allStrapiHome {
35
+ nodes {
36
+ body {
37
+ strapi_component
38
+ backgroundImage {
39
+ url
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ ` )
46
+
47
+ const heroBlock = allStrapiHome . nodes [ 0 ] . body . find (
48
+ b => b . strapi_component === "home.video-background"
49
+ )
50
+
51
+ const raw = heroBlock ?. backgroundImage ?. url
52
+ const heroUrl = raw
53
+ ? raw . startsWith ( "http" )
54
+ ? raw
55
+ : `https://strapi-s3-bitlogic.s3.sa-east-1.amazonaws.com${ raw } `
56
+ : null
57
+
30
58
return (
31
59
< ThemeProvider >
60
+ < Helmet >
61
+ < meta name = "viewport" content = "width=device-width, initial-scale=1" />
62
+ { /* 🔻 Preload eliminado para evitar error CORS */ }
63
+ </ Helmet >
64
+
32
65
{ options . hasHeader && < Header /> }
66
+
33
67
{ userLanguage ?. startsWith ( "en" ) && (
34
- < Suspense fallback >
68
+ < Suspense fallback = { null } >
35
69
< BannerRedirect />
36
70
</ Suspense >
37
71
) }
72
+
38
73
< main > { children } </ main >
74
+
39
75
{ options . hasFooter && < Footer /> }
40
- { /*© {new Date().getFullYear()}, Built with*/ }
41
76
</ ThemeProvider >
42
77
)
43
78
}
0 commit comments