diff --git a/lib/jekyll-seo-tag.rb b/lib/jekyll-seo-tag.rb index 2edafd7d..f76fe216 100644 --- a/lib/jekyll-seo-tag.rb +++ b/lib/jekyll-seo-tag.rb @@ -12,6 +12,7 @@ class SeoTag < Liquid::Tag autoload :UrlHelper, "jekyll-seo-tag/url_helper" autoload :Drop, "jekyll-seo-tag/drop" autoload :Filters, "jekyll-seo-tag/filters" + autoload :Webmaster, "jekyll-seo-tag/webmaster" attr_accessor :context diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index 157babd4..87177e7f 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -73,6 +73,10 @@ def title end # rubocop:enable Metrics/CyclomaticComplexity + def webmaster_verifications + Webmaster.render(site["webmaster_verifications"]) + end + def name return @name if defined?(@name) diff --git a/lib/jekyll-seo-tag/webmaster.rb b/lib/jekyll-seo-tag/webmaster.rb new file mode 100644 index 00000000..7b2578f0 --- /dev/null +++ b/lib/jekyll-seo-tag/webmaster.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Jekyll + class SeoTag + class Webmaster + META_MAP = { + "alexa" => "alexaVerifyID", + "baidu" => "baidu-site-verification", + "bing" => "msvalidate.01", + "facebook" => "facebook-domain-verification", + "google" => "google-site-verification", + "yandex" => "yandex-verification", + }.freeze + META_KEYS = Set.new(META_MAP.keys).freeze + private_constant :META_MAP, :META_KEYS + + def self.render(data) + return unless data.is_a?(Hash) + + @render ||= data.map do |key, value| + %() if META_KEYS.include?(key) + end.join("\n") + end + end + private_constant :Webmaster + end +end diff --git a/lib/template.html b/lib/template.html index 8bc25d5a..fbe30880 100755 --- a/lib/template.html +++ b/lib/template.html @@ -88,29 +88,7 @@ {% endif %} {% if site.webmaster_verifications %} - {% if site.webmaster_verifications.google %} - - {% endif %} - - {% if site.webmaster_verifications.bing %} - - {% endif %} - - {% if site.webmaster_verifications.alexa %} - - {% endif %} - - {% if site.webmaster_verifications.yandex %} - - {% endif %} - - {% if site.webmaster_verifications.baidu %} - - {% endif %} - - {% if site.webmaster_verifications.facebook %} - - {% endif %} + {{ seo_tag.webmaster_verifications }} {% elsif site.google_site_verification %} {% endif %}