FIX: static page title should be consistent on client side and server side

This commit is contained in:
Arpit Jalan 2018-11-27 21:49:59 +05:30
parent 04558b6ca4
commit bdb1268528
3 changed files with 16 additions and 3 deletions

View File

@ -10,6 +10,7 @@ class AboutController < ApplicationController
return redirect_to path('/login') if SiteSetting.login_required? && current_user.nil?
@about = About.new
@title = "#{I18n.t("js.about.simple_title")} - #{SiteSetting.title}"
respond_to do |format|
format.html do
render :index

View File

@ -39,7 +39,12 @@ class StaticController < ApplicationController
if map.has_key?(@page)
@topic = Topic.find_by_id(SiteSetting.send(map[@page][:topic_id]))
raise Discourse::NotFound unless @topic
@title = "#{@topic.title} - #{SiteSetting.title}"
title_prefix = if I18n.exists?("js.#{@page}")
I18n.t("js.#{@page}")
else
@topic.title
end
@title = "#{title_prefix} - #{SiteSetting.title}"
@body = @topic.posts.first.cooked
@faq_overriden = !SiteSetting.faq_url.blank?
render :show, layout: !request.xhr?, formats: [:html]

View File

@ -105,6 +105,13 @@
<% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% if @title %>
<% content_for :title do %><%= @title %><% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: @title, description: SiteSetting.site_description) %>
<% end %>
<% else %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: SiteSetting.title, description: SiteSetting.site_description) %>
<% end %>
<% end %>