Sha256: 14d09f35307fec35986b26ea8e8ffed87a2d3d2327492273e0858d3939b8d5b3

Contents?: true

Size: 820 Bytes

Versions: 9

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module BridgetownPrismic
  module Roda
    module Previews
      def prismic_preview_token
        request.params["token"] || request.cookies[Prismic::PREVIEW_COOKIE]
      end

      def save_prismic_preview_token
        bridgetown_site.config.prismic_preview_token = prismic_preview_token
      end

      def prismic_preview_redirect_url
        save_prismic_preview_token
        response.set_cookie Prismic::PREVIEW_COOKIE, bridgetown_site.config.prismic_preview_token
        BridgetownPrismic.api.preview_session(
          bridgetown_site.config.prismic_preview_token,
          bridgetown_site.config.prismic_link_resolver,
          "/"
        )
      end

      def prismic_token_error_msg
        "A valid Prismic preview token was not provided."
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bridgetown-prismic-1.0.1 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-1.0.0 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.3.0 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.2.3 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.2.2 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.2.1 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.2.0 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.1.2 lib/bridgetown-prismic/roda/previews.rb
bridgetown-prismic-0.1.1 lib/bridgetown-prismic/roda/previews.rb