mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:13:38 +08:00
FEATURE: Add support for custom site name in Open Graph metadata (#25373)
This commit is contained in:
parent
93264da206
commit
a37d26f559
|
@ -301,7 +301,7 @@ module ApplicationHelper
|
|||
) if opts[:twitter_summary_large_image].present?
|
||||
|
||||
result = []
|
||||
result << tag(:meta, property: "og:site_name", content: SiteSetting.title)
|
||||
result << tag(:meta, property: "og:site_name", content: opts[:site_name] || SiteSetting.title)
|
||||
result << tag(:meta, property: "og:type", content: "website")
|
||||
|
||||
generate_twitter_card_metadata(result, opts)
|
||||
|
|
|
@ -687,6 +687,27 @@ RSpec.describe ApplicationHelper do
|
|||
expect(metadata).to include output_tags
|
||||
end
|
||||
end
|
||||
|
||||
context "with custom site name" do
|
||||
before { SiteSetting.title = "Default Site Title" }
|
||||
|
||||
it "uses the provided site name in og:site_name" do
|
||||
custom_site_name = "Custom Site Name"
|
||||
result = helper.crawlable_meta_data(site_name: custom_site_name)
|
||||
|
||||
expect(result).to include(
|
||||
"<meta property=\"og:site_name\" content=\"#{custom_site_name}\" />",
|
||||
)
|
||||
end
|
||||
|
||||
it "falls back to the default site title if no custom site name is provided" do
|
||||
result = helper.crawlable_meta_data
|
||||
|
||||
expect(result).to include(
|
||||
"<meta property=\"og:site_name\" content=\"#{SiteSetting.title}\" />",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "discourse_color_scheme_stylesheets" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user