mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-24 05:05:53 +08:00
Make index.html interpolation instructions less clashing with env syntax
This commit is contained in:
@@ -705,11 +705,11 @@ Since Create React App doesn’t 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user