Class: Seo::PostCommentsSchemaBuilder
- Inherits:
-
Object
- Object
- Seo::PostCommentsSchemaBuilder
- Defined in:
- app/services/seo/post_comments_schema_builder.rb
Overview
Builds Schema.org JSON-LD nodes for a blog post's comment threads.
Threads where a WarmlyYours employee has replied are promoted to a
+Question+ with the first employee reply as +acceptedAnswer+ (an +Answer+).
Other replies on a Q&A thread are nested as +comment+. Threads with no
employee reply remain a generic +Comment+ with nested +Comment+ replies.
Returns an Array of +SchemaDotOrg::Comment+ and +SchemaDotOrg::Question+
instances suitable for assignment to +BlogPosting#comment+.
Constant Summary collapse
- USER_TEXT_TRUNCATE =
500
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(parent_comments) ⇒ PostCommentsSchemaBuilder
constructor
A new instance of PostCommentsSchemaBuilder.
Constructor Details
#initialize(parent_comments) ⇒ PostCommentsSchemaBuilder
Returns a new instance of PostCommentsSchemaBuilder.
16 17 18 |
# File 'app/services/seo/post_comments_schema_builder.rb', line 16 def initialize(parent_comments) @parents = parent_comments end |
Instance Method Details
#call ⇒ Object
20 21 22 |
# File 'app/services/seo/post_comments_schema_builder.rb', line 20 def call grouped_parents.map { |parent, synthetic| build(parent, synthetic) }.compact end |