Sha256: a286ce871b35788a72ca79b502fb82c6825d04049ca56690b740d924710f2db7

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

# Adds SEO tags
#
# == Basic usage:
#    {%seo%}
#
class SeoTag < LiquidumTag
  def render(context)
    super

    content = context.registers['content']
    site = content.site
    request = context.registers['controller'].request

    %[
<!-- Begin Scribo SEO tag #{Scribo::VERSION} -->
<title>#{site.properties['title']}</title>
<meta name="generator" content="Scribo #{Scribo::VERSION}" />
<meta property="og:title" content="#{content.site.title}" />
<meta name="author" content="#{site.properties['author'].is_a?(String) ? site.properties['author'] : ''}" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="#{site.properties['description']}" />
<meta property="og:description" content="#{site.properties['description']}" />
<link rel="canonical" href="#{request.protocol + request.host}" />
<meta property="og:url" content="#{request.protocol + request.host}" />
<meta property="og:site_name" content="#{content.site.title}" />
<script type="application/ld+json">
{"url":"#{request.protocol + request.host}","headline":"#{site.properties['title']}","name":"#{site.properties['title']}","author":{"@type":"Person","name":"#{site.properties['author']}"},"description":"#{site.properties['description']}","@type":"WebSite","@context":"https://schema.org"}</script>
<!-- End Scribo SEO tag -->
    ]
  end
end

Liquid::Template.register_tag('seo', SeoTag)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
scribo-1.0.44 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.43 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.42 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.41 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.40 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.39 lib/scribo/liquid/tags/seo_tag.rb
scribo-1.0.38 lib/scribo/liquid/tags/seo_tag.rb