stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.07k stars 392 forks source link

How to make multilingual website in react-snap #304

Closed athimannil closed 5 years ago

athimannil commented 5 years ago

I have multilingual website in like http://demo.com/, http://demo.de/, http://demo.nl/ and http://demo.dk/ which done by react-snap

Unfortunately SEO rendering only demo.de meta datas

Is there any option to use multilingual website in react-snap ?

index.js

const MOUNT_NODE = document.getElementById('app')
const appStructure = <Provider store={store}>
  <LanguageProvider>
    <ConnectedRouter history={history}>
      <ThemeProvider theme={theme}>
        <ABDecider>
          <App />
        </ABDecider>
      </ThemeProvider>
    </ConnectedRouter>
  </LanguageProvider>
</Provider>

const render = () => {
  if (MOUNT_NODE.hasChildNodes()) {
    ReactDOM.hydrate(
      appStructure,
      MOUNT_NODE
    )
  } else {
    ReactDOM.render(
      appStructure,
      MOUNT_NODE
    )
  }
}

package.json

      "reactSnap": {
        "source": "dist",
        "crawl": false,
        "include": [
          "/",
          "/friends"
          ]
      }
    }
}
stereobooster commented 5 years ago

In provided configuration, I guess, not. react-snap can generate different languages if they are defined by url, for example:

/de/friends
/da/friends

Or you need to find a way to pass language config to <LanguageProvider>

stereobooster commented 5 years ago

I will close this for now, feel free to ask more questions

Fluorz commented 5 years ago

I'm working on a multilingual website.

xxxxx.com => English xxxxx.fr => French

But all URLs are the same.

xxxxx.com/profile => profile of a user in English xxxxx.fr/profile => profile of a user in French

When I run react-snap, it generates static HTML with default language (French).

How can I use react-snap for a multilingual website without changing slug?