FEATURE: add title tag for group detail page (#13702)

This commit is contained in:
Arpit Jalan 2021-07-12 20:05:57 +05:30 committed by GitHub
parent d9eb37be70
commit 953fd2cb50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -121,6 +121,7 @@ class GroupsController < ApplicationController
format.html do
@title = group.full_name.present? ? group.full_name.capitalize : group.name
@full_title = "#{@title} - #{SiteSetting.title}"
@description_meta = group.bio_cooked.present? ? PrettyText.excerpt(group.bio_cooked, 300) : @title
render :show
end

View File

@ -1,3 +1,5 @@
<% content_for :title do %><%= @full_title %><% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: @title, description: @description_meta) %>
<% end %>

View File

@ -33,7 +33,7 @@ describe RetrieveTitle do
expect(title).to eq("Good Title")
end
it "will prefer the title from an opengraph tag" do
it "will prefer the title over the opengraph tag" do
title = RetrieveTitle.extract_title(<<~HTML
<html>
<title>Good Title</title>

View File

@ -411,6 +411,7 @@ describe GroupsController do
expect(response.status).to eq(200)
expect(response.body).to have_tag "title", text: "#{group.name} - #{SiteSetting.title}"
expect(response.body).to have_tag(:meta, with: {
property: 'og:title', content: group.name
})