Skip to content

Commit 74bed78

Browse files
feat: add seo relevant files (#376)
* add robots.txt * add to hosting guide * add sitemap.xml and script
1 parent 9e8b52d commit 74bed78

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

create-sitemap.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { sitemapBuilder as buildSitemap } from "react-router-sitemap";
2+
3+
var fs = require("fs");
4+
5+
const regex = /pages: (\[[\w\W]+?\])/gm;
6+
7+
let source = regex.exec(fs.readFileSync("./apps/official/index.ts").toString())[1];
8+
//console.log(source);
9+
10+
let ignorePaths = ["questions"];
11+
let pathPrefix = "/#/";
12+
13+
var paths = source
14+
.split(",")
15+
.map((x) => x.split(":").map((y) => y.trim()))
16+
.reduce((a, x) => {
17+
if (x[0] == "route") {
18+
let route = x[1].replace(/["'/]/g, "");
19+
if (ignorePaths.findIndex((p) => route === p) == -1) {
20+
a.push(pathPrefix + route);
21+
}
22+
}
23+
return a;
24+
}, []);
25+
26+
const hostname = "https://www.covmap.de";
27+
const sitemap = buildSitemap(hostname, paths);
28+
console.log(sitemap);
29+
30+
const { createWriteStream } = require("fs");
31+
const { SitemapStream } = require("sitemap");
32+
33+
// Creates a sitemap object given the input configuration with URLs
34+
const sitemapSteam = new SitemapStream(sitemap);
35+
36+
const writeStream = createWriteStream("./static/sitemap.xml");
37+
sitemapSteam.pipe(writeStream);
38+
paths.forEach((path) => {
39+
sitemapSteam.write(path);
40+
});
41+
42+
sitemapSteam.end();

hosting/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## Setup
2+
3+
# Preparation
4+
5+
Get a `Ubuntu 20.04.1 LTS` Server (e.g. 2 cores 4 GB RAM)
6+
7+
1. [Install Docker](https://docs.docker.com/engine/install/ubuntu/)
8+
2. [Install Docker Compose](https://docs.docker.com/compose/install/)
9+
3. Clone this repo
10+
111
# First Startup
212

313
1. `chmod +x setup.sh`

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@
9595
"prettier": "2.1.2",
9696
"react-hot-loader": "^4.12.20",
9797
"react-map-gl": "^5.2.3",
98+
"react-router-sitemap": "^1.2.0",
9899
"react-test-renderer": "^16.13.1",
99100
"redux-persist": "^6.0.0",
100101
"redux-persist-transform-filter": "^0.0.20",
101102
"semantic-release": "^17.2.1",
103+
"sitemap": "^6.3.3",
102104
"style-loader": "^1.1.3",
103105
"testcafe": "^1.9.4",
104106
"testcafe-browser-provider-browserstack": "^1.13.1",

static/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-Agent: *
2+
Disallow:

static/sitemap.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://www.covmap.de/#/charts</loc></url><url><loc>https://www.covmap.de/#/faq</loc></url><url><loc>https://www.covmap.de/#/credits</loc></url><url><loc>https://www.covmap.de/#/imprint</loc></url><url><loc>https://www.covmap.de/#/legal</loc></url><url><loc>https://www.covmap.de/#/privacy-statement</loc></url><url><loc>https://www.covmap.de/#/recommendations</loc></url><url><loc>https://www.covmap.de/#/rki</loc></url><url><loc>https://www.covmap.de/#/contact-behavior</loc></url><url><loc>https://www.covmap.de/#/symptom-level</loc></url></urlset>

0 commit comments

Comments
 (0)