Skip to content

Commit 3c50ec6

Browse files
Update sitemap (#1476)
* script to generate sitemap * update sitemap
1 parent 8c1b193 commit 3c50ec6

File tree

2 files changed

+13128
-7860
lines changed

2 files changed

+13128
-7860
lines changed

scripts/generate-sitemap.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
# Array of IDs
4+
gtfs_id=(
5+
6+
)
7+
8+
gtfs_rt_ids=(
9+
10+
)
11+
12+
gbfs_ids=(
13+
14+
)
15+
16+
# Base URL
17+
base_url_gtfs="https://mobilitydatabase.org/feeds/gtfs"
18+
base_url_gtfs_rt="https://mobilitydatabase.org/feeds/gtfs_rt"
19+
base_url_gbfs="https://mobilitydatabase.org/feeds/gbfs"
20+
21+
# Output folder and file
22+
output_folder="web-app/public"
23+
sitemap_file="${output_folder}/sitemap.xml"
24+
lastmod=$(date +%Y-%m-%d) # Use current date as the last modified date
25+
26+
# Ensure the output folder exists
27+
mkdir -p "$output_folder"
28+
29+
# Generate sitemap header
30+
cat <<EOL > "$sitemap_file"
31+
<?xml version="1.0" encoding="UTF-8"?>
32+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33+
<url>
34+
<loc>https://mobilitydatabase.org/feeds/</loc>
35+
<lastmod>${lastmod}</lastmod>
36+
<changefreq>weekly</changefreq>
37+
<priority>0.9</priority>
38+
</url>
39+
EOL
40+
41+
# Add each URL to the sitemap
42+
for id in "${gtfs_id[@]}"; do
43+
url="${base_url_gtfs}/${id}"
44+
45+
cat <<EOL >> "$sitemap_file"
46+
<url>
47+
<loc>${url}</loc>
48+
<lastmod>${lastmod}</lastmod>
49+
<changefreq>weekly</changefreq>
50+
<priority>0.7</priority>
51+
</url>
52+
EOL
53+
done
54+
# Add each URL to the sitemap
55+
for id in "${gtfs_rt_ids[@]}"; do
56+
url="${base_url_gtfs_rt}/${id}"
57+
58+
cat <<EOL >> "$sitemap_file"
59+
<url>
60+
<loc>${url}</loc>
61+
<lastmod>${lastmod}</lastmod>
62+
<changefreq>weekly</changefreq>
63+
<priority>0.7</priority>
64+
</url>
65+
EOL
66+
done
67+
# Add each URL to the sitemap
68+
for id in "${base_url_gbfs[@]}"; do
69+
url="${base_url_gbfs}/${id}"
70+
71+
cat <<EOL >> "$sitemap_file"
72+
<url>
73+
<loc>${url}</loc>
74+
<lastmod>${lastmod}</lastmod>
75+
<changefreq>weekly</changefreq>
76+
<priority>0.7</priority>
77+
</url>
78+
EOL
79+
done
80+
81+
# Close the sitemap
82+
echo "</urlset>" >> "$sitemap_file"
83+
84+
echo "Sitemap generated successfully: $sitemap_file"

0 commit comments

Comments
 (0)