Sha256: bda93b461cdd9ebb9c812efd65f728665345ba51ad2ac13b6c410dce34237031
Contents?: true
Size: 1.09 KB
Versions: 15
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module Maglev module RenderingConcern extend ActiveSupport::Concern included do include Maglev::FetchersConcern end private def render_maglev_page raise ActionController::UnknownFormat, 'Maglev renders HTML pages only' if request.format != 'html' fetch_maglev_page_content verify_canonical_path and return render template: fetch_maglev_theme_layout, layout: false end def verify_canonical_path # the section mode is only used to display the content of a single section # in the admin UI. return if maglev_rendering_mode == :section # check if we're processing the right version (canonical) of the page # if not, follow the proper SEO rule by redirecting the user with a 301 canonical_path = maglev_page.path return false if !canonical_path || params[:path] == canonical_path next_path = maglev_rendering_mode == :editor ? site_preview_path(path: canonical_path) : "/#{canonical_path}" redirect_to next_path, status: :moved_permanently true end end end
Version data entries
15 entries across 15 versions & 1 rubygems