Files
owenrees 37e0ac8e56 Transactional mail, crawler metadata, and asset measurement (#179)
* Send transactional email from no-reply@mail.innersquare.app

Centralise the sender identity, reply-to address and SES configuration set in Chesstrainer.Mail so no notifier can drift. Add MAIL_REDIRECT_TO for smoke tests and a mix mail.check task that exercises the SES mailbox simulators, and document the setup in the deploy guide and .env.example.

* Tighten crawler metadata and keep play pages out of search

Canonical URLs no longer carry query strings, public pages get an OG image, WebSite JSON-LD and a per-page language, and the sitemap dates the landing page only. Play and guest-training routes are marked noindex so tens of thousands of near-identical pages stay out of the index.

* Measure built asset sizes with mix assets.sizes

Report raw, gzip and brotli sizes for built JS and CSS, and record the current numbers plus the board-code split recommendation in docs/assets.md.
2026-11-17 10:29:45 +01:00

50 lines
1.3 KiB
Elixir

defmodule ChesstrainerWeb.SEO do
@moduledoc """
Absolute URLs and crawler metadata for controller-rendered pages.
Search engines need absolute URLs, so these helpers read the endpoint's
configured host rather than the request host (which is a proxy address).
Canonical URLs deliberately drop the query string: campaign parameters such
as `?utm_source=...` must not become canonical pages of their own.
"""
alias Chesstrainer.Branding
alias ChesstrainerWeb.Endpoint
@og_image "/images/og.png"
@logo "/apple-touch-icon.png"
@doc "The request path as an absolute canonical URL, without any query string."
def canonical_url(conn) do
Phoenix.VerifiedRoutes.unverified_url(conn, conn.request_path)
end
@doc "Absolute URL of the social share image."
def og_image_url, do: Endpoint.url() <> @og_image
@doc """
JSON-LD for the site, encoded as a string ready for a
`<script type="application/ld+json">` block.
"""
def json_ld(url) do
%{
"@context" => "https://schema.org",
"@graph" => [
%{
"@type" => "WebSite",
"name" => Branding.name(),
"url" => url
},
%{
"@type" => "Organization",
"name" => Branding.name(),
"url" => url,
"logo" => Endpoint.url() <> @logo
}
]
}
|> Jason.encode!()
end
end