We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a2c5c75 commit d3066e1Copy full SHA for d3066e1
app/controllers/docs_controller.rb
@@ -29,6 +29,13 @@ def show
29
@content = Kramdown::Document.new(@doc.content, input: 'GFM').to_html
30
@url = request.url
31
@meta_image = Nokogiri::HTML.parse(@content).at("//img")&.attribute('data-src')&.value || "/img/ogp-docs.jpeg"
32
+ if @meta_image.end_with? '.webp'
33
+ # .webp -> .jpg
34
+ # .webp -> .png
35
+ @meta_image.gsub!('.webp', '.jpg') if File.exists? "public/#{@meta_image[0..-6]}.jpg"
36
+ @meta_image.gsub!('.webp', '.jpeg') if File.exists? "public/#{@meta_image[0..-6]}.jpeg"
37
+ @meta_image.gsub!('.webp', '.png') if File.exists? "public/#{@meta_image[0..-6]}.png"
38
+ end
39
40
# Add here if you want to optimize meta description.
41
case @doc.filename
0 commit comments