scrivener_html_semi v3.0.1 Scrivener.HTML.SEO View Source

SEO related functions for pagination.

See Indicating paginated content to Google for more information.

Link to this section Summary

Functions

Produces <link/> tags for putting in the <head> to help SEO.

Produces the value for a rel attribute in an <a> tag. Returns either "next", "prev" or "canonical".

Link to this section Functions

Link to this function

header_links(page, opts \\ [])

View Source

Produces <link/> tags for putting in the <head> to help SEO.

The arguments passed in are the same as Scrivener.HTML.pagination/2.

See SEO Tags in Phoenix to know about how to do that.

iex> Scrivener.HTML.SEO.header_links(%Scrivener.Page{total_pages: 10, page_number: 3}) |> Phoenix.HTML.safe_to_string
"<link href=\"?page=2\" rel=\"prev\">\n<link href=\"?page=4\" rel=\"next\">"

Produces the value for a rel attribute in an <a> tag. Returns either "next", "prev" or "canonical".

iex> Scrivener.HTML.SEO.rel(%Scrivener.Page{page_number: 5}, 4)
"prev"

iex> Scrivener.HTML.SEO.rel(%Scrivener.Page{page_number: 5}, 6)
"next"

iex> Scrivener.HTML.SEO.rel(%Scrivener.Page{page_number: 5}, 8)
"canonical"

Scrivener.HTML.pagination/2 will use this module to add rel attribute to each link.