From 76090f6d604aa17233c8bcfb7b7734b64e163de0 Mon Sep 17 00:00:00 2001 From: Gregoire Date: Mon, 6 Sep 2021 16:39:11 +0200 Subject: [PATCH] fix(gatsby): ssr with script --- .gitignore | 1 + src/app/website/gatsby-ssr.js | 41 +- src/app/website/src/components/seo.tsx | 4 +- src/app/website/yarn.lock | 4477 +++++++----------------- test/integration/bulle-extension.js | 11 + 5 files changed, 1297 insertions(+), 3237 deletions(-) diff --git a/.gitignore b/.gitignore index bdd5c0e1f..36a94e43a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ yarn-error.log /src/app/website/.cache /src/app/website/node_modules /src/app/website/public +/src/app/website/static/script/profiles/ diff --git a/src/app/website/gatsby-ssr.js b/src/app/website/gatsby-ssr.js index 876b7ed9d..e832b6858 100644 --- a/src/app/website/gatsby-ssr.js +++ b/src/app/website/gatsby-ssr.js @@ -8,15 +8,46 @@ // eslint-disable-next-line @typescript-eslint/no-var-requires const React = require('react'); -exports.onRenderBody = ({ setHeadComponents, pathname }) => { - console.log('pathname', pathname); - console.log(pathname === 'fr/profiles' && 'coucou'); - setHeadComponents([ +exports.onRenderBody = ({ + pathname, + setPreBodyComponents, + setPostBodyComponents +}) => { + const profilesRegex = new RegExp('profiles', 'g'); + console.warn( + "!!, Le path n'est généré que au PROD build sur Gatsby", + 'profilesRegex.test(pathname)', + pathname, + profilesRegex.test(pathname) + ); + setPreBodyComponents([
]); + setPostBodyComponents([