From 328ac7bedfe5aa5b86cce74500353ad49d34597f Mon Sep 17 00:00:00 2001 From: Kristofer Selbekk Date: Sun, 7 Oct 2018 20:07:28 +0200 Subject: [PATCH] Move injecting data from the server into the page into its own file --- ...ecting-data-from-the-server-into-the-page.md | 17 +++++++++++++++++ docusaurus/docs/user-guide.md | 16 ---------------- docusaurus/website/sidebars.json | 7 +++---- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 docusaurus/docs/injecting-data-from-the-server-into-the-page.md diff --git a/docusaurus/docs/injecting-data-from-the-server-into-the-page.md b/docusaurus/docs/injecting-data-from-the-server-into-the-page.md new file mode 100644 index 00000000..ab428a62 --- /dev/null +++ b/docusaurus/docs/injecting-data-from-the-server-into-the-page.md @@ -0,0 +1,17 @@ +--- +id: injecting-data-from-the-server-into-the-page +title: Injecting Data from the Server into the Page +--- + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** diff --git a/docusaurus/docs/user-guide.md b/docusaurus/docs/user-guide.md index 1af8a028..f6a2469d 100644 --- a/docusaurus/docs/user-guide.md +++ b/docusaurus/docs/user-guide.md @@ -11,7 +11,6 @@ You can find the most recent version of this guide [here](https://github.com/fac ## Table of Contents -- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) - [Making a Progressive Web App](#making-a-progressive-web-app) - [Why Opt-in?](#why-opt-in) - [Offline-First Considerations](#offline-first-considerations) @@ -19,21 +18,6 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Advanced Configuration](#advanced-configuration) - [Alternatives to Ejecting](#alternatives-to-ejecting) -## Injecting Data from the Server into the Page - -Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: - -```js - - - - -``` - -Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** - ## Making a Progressive Web App The production build has all the tools necessary to generate a first-class diff --git a/docusaurus/website/sidebars.json b/docusaurus/website/sidebars.json index 0d44eb87..dd5bc75b 100644 --- a/docusaurus/website/sidebars.json +++ b/docusaurus/website/sidebars.json @@ -33,11 +33,13 @@ "adding-relay", "adding-a-router", "adding-custom-environment-variables", + "can-i-use-decorators", "fetching-data-with-ajax-requests", "integrating-with-an-api-backend", "using-https-in-development", "generating-dynamic-meta-tags-on-the-server", - "pre-rendering-into-static-html-files" + "pre-rendering-into-static-html-files", + "injecting-data-from-the-server-into-the-page" ], "Testing": ["running-tests", "debugging-tests"], "Deployment": ["publishing-components-to-npm", "deployment"], @@ -46,9 +48,6 @@ "updating-to-new-releases", "sending-feedback", "something-missing" - ], - "Frequently Asked Questions": [ - "can-i-use-decorators" ] } }