StaticBlog.SEO (StaticBlog v0.2.0)

Copy Markdown View Source

Builds JSON-LD structured-data payloads for each page type.

Summary

Functions

Return a JSON-encoded BlogPosting structured data payload for a single post.

Return a JSON-encoded BreadcrumbList payload for a category page.

Return a JSON-encoded BreadcrumbList payload for a single post.

Return a JSON-encoded CollectionPage structured data payload for a category landing page.

Return a JSON-encoded WebSite structured data payload for the home page.

Return the absolute URL of the site's logo image.

Count words in a post body by stripping HTML tags and counting whitespace-delimited tokens.

Functions

json_ld_blog_posting(post, site)

@spec json_ld_blog_posting(
  StaticBlog.Post.t(),
  keyword()
) :: binary()

Return a JSON-encoded BlogPosting structured data payload for a single post.

Arguments

Returns

  • A binary containing the JSON-LD document.

json_ld_breadcrumbs_for_category(tag, site)

@spec json_ld_breadcrumbs_for_category(
  String.t(),
  keyword()
) :: binary()

Return a JSON-encoded BreadcrumbList payload for a category page.

Arguments

  • tag is the human-readable tag name.

  • site is the site configuration keyword list.

Returns

  • A binary containing the JSON-LD document.

json_ld_breadcrumbs_for_post(post, site)

@spec json_ld_breadcrumbs_for_post(
  StaticBlog.Post.t(),
  keyword()
) :: binary()

Return a JSON-encoded BreadcrumbList payload for a single post.

Arguments

  • post is the StaticBlog.Post.t/0 to generate breadcrumbs for.

  • site is the site configuration keyword list.

Returns

  • A binary containing the JSON-LD document.

json_ld_collection_page(tag, posts, site)

@spec json_ld_collection_page(String.t(), [StaticBlog.Post.t()], keyword()) ::
  binary()

Return a JSON-encoded CollectionPage structured data payload for a category landing page.

Arguments

  • tag is the human-readable tag name.

  • posts is the list of posts in this category.

  • site is the site configuration keyword list.

Returns

  • A binary containing the JSON-LD document.

json_ld_website(site)

@spec json_ld_website(keyword()) :: binary()

Return a JSON-encoded WebSite structured data payload for the home page.

Arguments

  • site is the site configuration keyword list.

Returns

  • A binary containing the JSON-LD document.

logo_url(site)

@spec logo_url(keyword()) :: String.t()

Return the absolute URL of the site's logo image.

Arguments

  • site is the site configuration keyword list.

Returns

  • An absolute URL string.

word_count(post)

@spec word_count(StaticBlog.Post.t()) :: non_neg_integer()

Count words in a post body by stripping HTML tags and counting whitespace-delimited tokens.

Arguments

  • post is the post whose body to count.

Returns

  • A non-negative integer word count.