Xeo (xeo v0.1.0)
Elegantly generate seo and social tags for your Phoenix app.
When used, this module will inject the seo/1
and other macros in your module,
which you can then use to elegantly define the tags for your pages.
Usage
defmodule MySeo
use Xeo
# OR
use Xeo, opts
end
Use Options
:router
(optional): Your app's router name which will be used to verify the routes if the:warn
options is set totrue
(the defaults toYourAppsName.Router
):warn
(optional): A boolean flag which specifies whether to emit compile time warnings if the seo macro was not defined for some path. (defaults totrue
):pad
(optional): An option for formatting the final HTML tags. This option specifies how much leading space to add prior to each meta tag (defaults to4
spaces)
Example
defmodule MyApp.Seo do
use Xeo
# use Xeo, warn: false, pad: 2
seo "/" do
title "Some page"
description "Some SEO description"
og_title "Welcome"
og_image "https://example.com/image.jpg"
og_description "Some SEO description"
...
end
seo "/contact" do
title: "Contact Us"
description "Our contact page is awesome"
og_title "Contact us"
og_image fn -> Routes.static_path(Endpoint, "/images/image.jpg") end
og_description "Our contact page"
...
twitter_title: "Contact us"
end
end
Summary
Functions
Step over each GET
route and and check if an seo function was
defined for it, and if not, optionally show a compilation warning.
A macro for generating a function (named seo_for_path
)
that will match on conn.request_path
and will generate the corresponding meta tags.
Functions
check_routes(env, bytecode)
Step over each GET
route and and check if an seo function was
defined for it, and if not, optionally show a compilation warning.
A macro for generating a function (named seo_for_path
)
that will match on conn.request_path
and will generate the corresponding meta tags.