Fix prerender
parent
5bca6eeb02
commit
ce61599db5
|
@ -31,7 +31,7 @@ export default async ({ site, url, lang }) => {
|
|||
.replace('<!--app-style-->', styleTags)
|
||||
.replace(regexHelmet, helmet.title.toString() + helmet.meta.toString())
|
||||
|
||||
const dir = path.join(dirname, 'dist/prerender', site, url)
|
||||
const dir = path.join(dirname, 'dist/prerender', site, decodeURI(url))
|
||||
|
||||
await fs.mkdir(dir, { recursive: true })
|
||||
await fs.writeFile(path.join(dir, 'index.html'), page)
|
||||
|
|
|
@ -17,7 +17,6 @@ export const pagesToPrerender: {
|
|||
'mon-entreprise': [
|
||||
sitePathFr.index,
|
||||
sitePathFr.créer.index,
|
||||
sitePathFr.gérer.index,
|
||||
sitePathFr.simulateurs.index,
|
||||
sitePathFr.simulateurs.salarié,
|
||||
sitePathFr.simulateurs['chômage-partiel'],
|
||||
|
@ -27,12 +26,12 @@ export const pagesToPrerender: {
|
|||
sitePathFr.simulateurs['artiste-auteur'],
|
||||
'/iframes/simulateur-embauche',
|
||||
'/iframes/pamc',
|
||||
].map((url) => decodeURI(url)),
|
||||
],
|
||||
infrance: [
|
||||
sitePathEn.index,
|
||||
sitePathEn.simulateurs.salarié,
|
||||
'/iframes/simulateur-embauche',
|
||||
].map((url) => decodeURI(url)),
|
||||
],
|
||||
}
|
||||
|
||||
const dev = argv.findIndex((val) => val === '--dev') > -1
|
||||
|
@ -50,7 +49,7 @@ const redirects = await Promise.all(
|
|||
return `
|
||||
[[redirects]]
|
||||
from = ":SITE_${site === 'mon-entreprise' ? 'FR' : 'EN'}${
|
||||
dev ? url : encodeURI(url)
|
||||
dev ? decodeURI(url) : url
|
||||
}"
|
||||
to = "/${path}"
|
||||
status = 200
|
||||
|
|
|
@ -13,6 +13,11 @@ export default function useSimulationConfig(
|
|||
) {
|
||||
const dispatch = useDispatch()
|
||||
|
||||
// Initialize redux store for SSR
|
||||
if (import.meta.env.SSR) {
|
||||
dispatch(setSimulationConfig(config ?? {}, path))
|
||||
}
|
||||
|
||||
const lastConfig = useSelector(configSelector)
|
||||
useEffect(() => {
|
||||
if (config && lastConfig !== config) {
|
||||
|
|
|
@ -28,9 +28,10 @@ export function render(url: string, lang: 'fr' | 'en') {
|
|||
</HelmetProvider>
|
||||
)
|
||||
|
||||
// first render
|
||||
// Render to initialize redux store (via useSimulationConfig)
|
||||
ReactDOMServer.renderToString(element)
|
||||
// second render with the configured engine
|
||||
|
||||
// Render with redux store configured
|
||||
const html = ReactDOMServer.renderToString(element)
|
||||
|
||||
const styleTags = sheet.getStyleTags()
|
||||
|
|
Loading…
Reference in New Issue