[deploy] Fixes a duplicate page title on the /videos page (#10170)
* Fixes a duplicate page title on the /videos page
So the `app/views/videos/index.html.erb` was invoking the `#title`
helper method 3 times.
In each invocation the helper method was calling
`content_for(:title) { derived_title }`. Looking at the `content_for`
documentation
[here](9055156668/actionview/lib/action_view/helpers/capture_helper.rb (L117)),
you can find the following comment:
```
Note that <tt>content_for</tt> concatenates (default) the blocks it is given
for a particular identifier in order. For example:
```
Which basically meant that each time the helper got invoked, the title
was appended to the end of the existing title.
This commit fixes the issue by making sure that the `#title` helper is
only invoked once by the view.
* Empty commit, trigger the build
This commit is contained in:
parent
0e8f48b5e7
commit
4c53c59d96
2 changed files with 12 additions and 4 deletions
|
|
@ -1,19 +1,19 @@
|
|||
<%= content_for :page_meta do %>
|
||||
<% title("#{community_name} Videos") %>
|
||||
<% page_title = title("Videos") %>
|
||||
|
||||
<%= content_for :page_meta do %>
|
||||
<link rel="canonical" href="<%= app_url(request.path) %>" />
|
||||
<meta name="description" content="<%= SiteConfig.community_description %>">
|
||||
<meta name="keywords" content="<%= SiteConfig.meta_keywords[:default] %>">
|
||||
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="<%= app_url(request.path) %>" />
|
||||
<meta property="og:title" content="<% title "Videos" %>" />
|
||||
<meta property="og:title" content="<%= page_title %>" />
|
||||
<meta property="og:image" content="<%= SiteConfig.main_social_image %>">
|
||||
<meta property="og:description" content="All videos on <%= community_name %>" />
|
||||
<meta property="og:site_name" content="<%= community_qualified_name %>" />
|
||||
|
||||
<meta name="twitter:site" content="@<%= SiteConfig.social_media_handles["twitter"] %>">
|
||||
<meta name="twitter:title" content="<% title "Videos" %>">
|
||||
<meta name="twitter:title" content="<%= page_title %>">
|
||||
<meta name="twitter:description" content="All videos on <%= community_name %>">
|
||||
<meta name="twitter:image:src" content="<%= SiteConfig.main_social_image %>">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ RSpec.describe "User visits the videos page", type: :system do
|
|||
|
||||
expect(page).to have_selector(selector, visible: :hidden)
|
||||
end
|
||||
|
||||
it "contains the expected title tags" do
|
||||
expected_title = "Videos - #{community_name}"
|
||||
|
||||
expect(page).to have_title(expected_title)
|
||||
expect(page).to have_selector("meta[property='og:title'][content='#{expected_title}']", visible: :hidden)
|
||||
expect(page).to have_selector("meta[name='twitter:title'][content='#{expected_title}']", visible: :hidden)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue