Revision 59305
Added by Konstantina Galouni over 3 years ago
server.ts | ||
---|---|---|
79 | 79 |
} |
80 | 80 |
next(); |
81 | 81 |
}); |
82 |
// - Serve sitemap based on the host - |
|
83 |
app.get('/sitemap.xml', (req, res) => { |
|
84 |
console.log(req.get("host")); |
|
85 |
let host = req.get("host").split(":")[0]; |
|
86 |
let connectLinks= ["/","/about/learn-how","/about/learn-in-depth", "/about/faq","/search/find/communities"]; |
|
87 |
let communityLinks= ["/","/search/find/research-outcomes","/search/advanced/research-outcomes","/participate/deposit/learn-how","/organizations", "/content"]; |
|
88 |
let sitemap = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
|
89 |
"<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">"; |
|
90 |
let urlPre = "<url>\n" + |
|
91 |
" <loc><![CDATA["; |
|
92 |
let urlSuf = "]]></loc>\n" + |
|
93 |
" </url>"; |
|
94 |
for(let link of (host.indexOf("connect.openaire.eu") == -1 ?communityLinks:connectLinks)){ |
|
95 |
sitemap += urlPre + "https://" + host + link + urlSuf; |
|
96 |
} |
|
97 |
sitemap += "\n</urlset>"; |
|
98 |
console.log(req.secure); |
|
99 |
res.setHeader('content-type', 'application/xml'); |
|
100 |
res.send( sitemap); |
|
101 |
}); |
|
82 | 102 |
|
83 | 103 |
/* - Example Express Rest API endpoints - |
84 | 104 |
app.get('/api/**', (req, res) => { }); |
Also available in: Unified diff
[use-UoaAdminToolsLibrary | Connect]: Merge trunk into branch.