Add meta tags
This commit is contained in:
parent
a395f6b80a
commit
514e15beab
@ -30,5 +30,8 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "^4.17.1"
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,15 @@
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
content="__DESCRIPTION__"
|
||||
/>
|
||||
<meta
|
||||
property="og:title"
|
||||
content="__TITLE__"
|
||||
/>
|
||||
<meta
|
||||
property="og:description"
|
||||
content="__DESCRIPTION__"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
@ -24,7 +32,7 @@
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
<title>__TITLE__</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
43
server.js
Normal file
43
server.js
Normal file
@ -0,0 +1,43 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const PORT = process.env.PORT || 5000;
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
const filePath = path.resolve(__dirname, "./build", "index.html");
|
||||
fs.readFile(filePath, "utf8", (err, data) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
data = data
|
||||
.replace(/__TITLE__/g, "Home Page")
|
||||
.replace(/__DESCRIPTION__/g, "Home page description.");
|
||||
|
||||
res.send(data)
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/about", (req, res) => {
|
||||
const filePath = path.resolve(__dirname, "./build", "index.html");
|
||||
fs.readFile(filePath, "utf8", (err, data) => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
data = data
|
||||
.replace(/__TITLE__/g, "About Page")
|
||||
.replace(/__DESCRIPTION__/g, "About page description.");
|
||||
|
||||
res.send(data)
|
||||
});
|
||||
});
|
||||
|
||||
app.use(express.static(path.resolve(__dirname, "./build")))
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server is listening on port ${PORT}`)
|
||||
})
|
Loading…
Reference in New Issue
Block a user