Extract h1 headings from ActionText content
Created by: equivalent
Summary
similar way how it's possible to extract ActionText Content links:
class Post < ApplicationRecord
has_rich_text :content
end
Post.last.content.body.links
# => ["http://localhost:3000/whatever"]
... it would be awesome if we could extract h1 headings:
Post.last.content.body.headings
# => ["Hello Rails"]
My use-case is that I want to extract title for post from the wysiwyg content
class Post < ApplicationRecord
has_rich_text :content
def title
content.body.headings.first
end
end