mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 03:32:06 +00:00
add sitemap, robots, and noindex admin routes (#85)
Serve a runtime sitemap.xml with the indexable marketing pages only; endgame play pages are left out to avoid indexing tens of thousands of near-identical pages. Generate robots.txt at runtime so it points at the sitemap on the deployment's host, and send X-Robots-Tag: noindex from every /admin response.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
defmodule ChesstrainerWeb.RobotsController do
|
||||
@moduledoc """
|
||||
Serves `/robots.txt` with a sitemap URL that follows the deployment's host.
|
||||
|
||||
Built at runtime from the endpoint configuration rather than checked in as a
|
||||
static file, so the sitemap stays correct across environments.
|
||||
"""
|
||||
|
||||
use ChesstrainerWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
body = """
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: #{url(conn, ~p"/sitemap.xml")}
|
||||
"""
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/plain")
|
||||
|> send_resp(200, body)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user