Add sitemap.txt
authorTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 23 May 2022 20:39:05 +0000 (16:39 -0400)
committerTheSaminator <TheSaminator@users.noreply.github.com>
Mon, 23 May 2022 20:39:05 +0000 (16:39 -0400)
src/jvmMain/kotlin/starshipfights/info/endpoints_info.kt
src/jvmMain/kotlin/starshipfights/server.kt

index dccb2306370f0fe4e9488ddfddab1282fb793855..6606d2798aadb94cbdb64915239dd2b19a6a47c1 100644 (file)
@@ -54,4 +54,21 @@ fun Routing.installPages() {
        get("/cache-time") {
                call.respondText(cacheTime, ContentType.Text.Plain, HttpStatusCode.OK)
        }
+       
+       // Sitemap
+       val sitemapUrls = (listOf(
+               "/",
+               "/about",
+               "/about/pp",
+               "/about/toc",
+               "/info",
+       ) + ShipType.values().map {
+               "/info/${it.toUrlSlug()}"
+       }).map { "https://starshipfights.net$it" }
+       
+       val sitemap = sitemapUrls.joinToString(separator = "\n")
+       
+       get("/sitemap.txt") {
+               call.respondText(sitemap, ContentType.Text.Plain, HttpStatusCode.OK)
+       }
 }
index 2383309f8327907b5c004a73f43e94050b187b24..370cd38b3f438a7caff7deadbcbec9461e4c3f07 100644 (file)
@@ -39,6 +39,7 @@ fun main() {
        val dataRoutines = DataRoutines.initializeRoutines()
        
        embeddedServer(Netty, port = CurrentConfiguration.port, host = CurrentConfiguration.host) {
+               install(IgnoreTrailingSlash)
                install(XForwardedHeaderSupport)
                
                install(CallId) {