GamendWeb.PageMeta (gamend_web v1.0.1215)

Copy Markdown View Source

Helpers for the host module behind GamendWeb.Plugs.PageMeta.

Every host answers "what is this page about" with its own copy, but the mechanics around that copy — normalising the path it is keyed by, stripping markdown out of it, cutting it to what a search engine shows, and turning a breadcrumb trail into BreadcrumbList markup — are the same everywhere.

Summary

Functions

trail as a schema.org BreadcrumbList, or nil when it has no ancestry.

An absolute URL for path under the locale being rendered.

The lookup form of path: no trailing slash, / for the root.

text as the plain prose a <meta name="description"> takes.

text cut to max characters at a word boundary.

An absolute URL for path.

Functions

locale_url(path)

@spec locale_url(String.t()) :: String.t()

An absolute URL for path under the locale being rendered.

normalize(path)

@spec normalize(String.t()) :: String.t()

The lookup form of path: no trailing slash, / for the root.

plain_text(text)

@spec plain_text(String.t() | nil) :: String.t() | nil

text as the plain prose a <meta name="description"> takes.

Descriptions are drawn from markdown — a post's excerpt, a guide's opening paragraph — where links and emphasis would otherwise reach the snippet as their own source characters.

truncate(text, max \\ 160)

@spec truncate(String.t() | nil, pos_integer()) :: String.t() | nil

text cut to max characters at a word boundary.

Defaults to the ~160 characters Google shows before it truncates.

url(path)

@spec url(String.t()) :: String.t()

An absolute URL for path.