Make index.html interpolation instructions less clashing with env syntax

This commit is contained in:
Dan Abramov
2017-02-11 13:45:30 +00:00
committed by GitHub
parent 67e6cf5a52
commit dc4e8bb462

View File

@@ -705,11 +705,11 @@ Since Create React App doesnt support server rendering, you might be wonderin
<!doctype html>
<html lang="en">
<head>
<meta property="og:title" content="%OG_TITLE%">
<meta property="og:description" content="%OG_DESCRIPTION%">
<meta property="og:title" content="__OG_TITLE__">
<meta property="og:description" content="__OG_DESCRIPTION__">
```
Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `%OG_TITLE%`, `%OG_DESCRIPTION%`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!
Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!
If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases.