# frozen_string_literal: true module Bridgetown module Plausible class Builder < Bridgetown::Builder def build liquid_tag "plausible" do |_attributes, tag| render.html_safe end helper "plausible" do render.html_safe end end private def render domain = options.dig(:domain)&.strip server = options.dig(:server)&.strip || "plausible.io" tag = if domain markup_for_snippet(domain, server) else Bridgetown.logger.warn "Plausible", "Domain not configured." markup_for_snippet("NOT CONFIGURED", server) end return wrap_with_comment(tag) unless Bridgetown.environment.production? tag end def markup_for_snippet(domain, server) "" end def wrap_with_comment(tag) "" end def options config["plausible"] || {} end end end end Bridgetown::Plausible::Builder.register