Sha256: e70d9e76b52693f0262690defb059aa950824ec7e86560d57eddf1743386ef5a
Contents?: true
Size: 1011 Bytes
Versions: 2
Compression:
Stored size: 1011 Bytes
Contents
# frozen_string_literal: true module Bridgetown module Plausible class Builder < Bridgetown::Builder def build liquid_tag "plausible" do |_attributes, tag| render end helper "plausible" do render end end private def render domain = options.dig(:domain)&.strip tag = if domain markup_for_domain(domain) else Bridgetown.logger.warn "Plausible", "Domain not configured." markup_for_domain("NOT CONFIGURED") end return wrap_with_comment(tag) unless Bridgetown.environment.production? tag end def markup_for_domain(domain) "<script async defer data-domain=\"#{domain}\" src=\"https://plausible.io/js/plausible.js\"></script>" end def wrap_with_comment(tag) "<!-- #{tag} -->" end def options config["plausible"] || {} end end end end Bridgetown::Plausible::Builder.register
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bridgetown-plausible-1.0.1 | lib/bridgetown-plausible/builder.rb |
bridgetown-plausible-1.0.0 | lib/bridgetown-plausible/builder.rb |