Skip to content
Snippets Groups Projects
Commit 589d5784 authored by Julien MARGAIL's avatar Julien MARGAIL
Browse files

fix image loading (svg / png) remove direct access v0.4.0

parent e120b0ad
Branches
Tags
No related merge requests found
{ {
"name": "@onegeo-suite/gatsby-theme-onegeo", "name": "@onegeo-suite/gatsby-theme-onegeo",
"version": "0.3.0", "version": "0.4.0",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",
"author": "NEOGEO", "author": "NEOGEO",
... ...
......
...@@ -15,23 +15,24 @@ const Footer = (props: Props) => { ...@@ -15,23 +15,24 @@ const Footer = (props: Props) => {
site { site {
logo { logo {
id id
imageFile {
childImageSharp {
gatsbyImageData
}
name
publicURL
}
} }
} }
} }
} }
`) `)
const idLogo = dataDirectus.directus.site.logo?.id const logo = dataDirectus.directus.site.logo?.imageFile
return ( return (
<footer className={`footer bg-base-300 items-center px-4 ${className}`}> <footer className={`footer bg-base-300 items-center px-4 ${className}`}>
<div className="grid-flow-col items-center"> <div className="grid-flow-col items-center">
<Logo <Logo title="" image={logo} url="/" className="w-10" />
title=""
image={`${process.env.DIRECTUS_URL}assets/${idLogo}`}
url="/"
className="w-10"
/>
</div> </div>
<div className="justify-self-center"> <div className="justify-self-center">
<Menu name="footer" className="menu menu-horizontal p-0" /> <Menu name="footer" className="menu menu-horizontal p-0" />
... ...
......
...@@ -21,6 +21,8 @@ const Header = (props: IHeader) => { ...@@ -21,6 +21,8 @@ const Header = (props: IHeader) => {
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
} }
} }
... ...
......
...@@ -39,6 +39,8 @@ const News = (props: INews) => { ...@@ -39,6 +39,8 @@ const News = (props: INews) => {
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
} }
} }
... ...
......
...@@ -18,6 +18,13 @@ const Partners = (props: Props) => { ...@@ -18,6 +18,13 @@ const Partners = (props: Props) => {
id id
logo { logo {
id id
imageFile {
childImageSharp {
gatsbyImageData
}
name
publicURL
}
} }
name name
url url
...@@ -28,7 +35,7 @@ const Partners = (props: Props) => { ...@@ -28,7 +35,7 @@ const Partners = (props: Props) => {
const partners = dataDirectus.directus.partners const partners = dataDirectus.directus.partners
const dataImage = partners.map((partner: any) => { const dataImage = partners.map((partner: any) => {
return { src: `${process.env.DIRECTUS_URL}assets/${partner.logo.id}` } return { src: partner.logo.imageFile }
}) })
return ( return (
... ...
......
...@@ -70,6 +70,8 @@ const GRAPHQL_QUERY = graphql` ...@@ -70,6 +70,8 @@ const GRAPHQL_QUERY = graphql`
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
id id
} }
... ...
......
...@@ -19,6 +19,13 @@ const Socials = (props: ISocials) => { ...@@ -19,6 +19,13 @@ const Socials = (props: ISocials) => {
id id
logo { logo {
id id
imageFile {
childImageSharp {
gatsbyImageData
}
name
publicURL
}
} }
} }
} }
...@@ -41,7 +48,7 @@ const Socials = (props: ISocials) => { ...@@ -41,7 +48,7 @@ const Socials = (props: ISocials) => {
key={key} key={key}
> >
<Logo <Logo
image={`${process.env.DIRECTUS_URL}assets/${item.logo.id}`} image={item.logo?.imageFile}
url={item.url} url={item.url}
className={"h-7 w-7"} className={"h-7 w-7"}
/> />
... ...
......
...@@ -34,15 +34,23 @@ const Image = (props: Iimage) => { ...@@ -34,15 +34,23 @@ const Image = (props: Iimage) => {
const img = getImage(image) const img = getImage(image)
if (typeof img == "undefined") { if (typeof img == "undefined") {
// SVG image
if (image.publicURL) {
return (
<img
src={image.publicURL}
alt={image.name}
className={imageClassname}
/>
)
}
return imageNoAvailable return imageNoAvailable
} }
// PNG image
return ( return (
<GatsbyImage <GatsbyImage image={img} alt={image.name} className={imageClassname} />
image={img}
alt="gatsby-image"
className={imageClassname}
/>
) )
} }
... ...
......
...@@ -18,6 +18,13 @@ const Marquee = () => { ...@@ -18,6 +18,13 @@ const Marquee = () => {
partners { partners {
logo { logo {
id id
imageFile {
childImageSharp {
gatsbyImageData
}
name
publicURL
}
} }
} }
} }
...@@ -64,7 +71,7 @@ const Marquee = () => { ...@@ -64,7 +71,7 @@ const Marquee = () => {
<div className="slide-content flex w-20 justify-center"> <div className="slide-content flex w-20 justify-center">
<div className="user-image"> <div className="user-image">
<Logo <Logo
image={`${process.env.DIRECTUS_URL}assets/${item.logo.id}`} image={item.logo.imageFile}
url={url} url={url}
className="user-photo w-16" className="user-photo w-16"
title="" title=""
... ...
......
...@@ -24,6 +24,8 @@ function hero() { ...@@ -24,6 +24,8 @@ function hero() {
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
} }
} }
... ...
......
...@@ -45,6 +45,8 @@ GraphQL query ...@@ -45,6 +45,8 @@ GraphQL query
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
} }
} }
... ...
......
...@@ -91,6 +91,8 @@ export const query = graphql` ...@@ -91,6 +91,8 @@ export const query = graphql`
childImageSharp { childImageSharp {
gatsbyImageData gatsbyImageData
} }
name
publicURL
} }
} }
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment