Skip to content

Commit ee4f5a9

Browse files
committed
Fix prefixed headings in guide pages meta descriptions
All descriptions and og:description meta tags currently are prefixed with the specific guide's h1. This happens when sanitizing the headers html fragment.
1 parent 5fc266a commit ee4f5a9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

guides/rails_guides/markdown.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def render(body)
2323
@raw_body = body
2424
extract_raw_header_and_body
2525
generate_header
26-
generate_description
2726
generate_title
27+
generate_description
2828
generate_body
2929
generate_structure
3030
generate_index
@@ -95,7 +95,7 @@ def generate_header
9595

9696
def generate_description
9797
sanitizer = Rails::Html::FullSanitizer.new
98-
@description = sanitizer.sanitize(@header).squish
98+
@description = sanitizer.sanitize(@header).squish.delete_prefix(@heading)
9999
end
100100

101101
def generate_structure
@@ -167,8 +167,8 @@ def generate_index
167167
end
168168

169169
def generate_title
170-
if heading = html_fragment(@header).at(:h1)
171-
@title = "#{heading.text} — Ruby on Rails Guides"
170+
if @heading = html_fragment(@header).at(:h1)
171+
@title = "#{@heading.text} — Ruby on Rails Guides"
172172
else
173173
@title = "Ruby on Rails Guides"
174174
end

0 commit comments

Comments
 (0)