Class: Decidim::Blogs::SchemaOrgBlogPostingPostSerializer
- Inherits:
-
Exporters::Serializer
- Object
- Exporters::Serializer
- Decidim::Blogs::SchemaOrgBlogPostingPostSerializer
- Includes:
- ActionView::Helpers::UrlHelper, SanitizeHelper, TranslationsHelper
- Defined in:
- lib/decidim/blogs/schema_org_blog_posting_post_serializer.rb
Instance Method Summary collapse
-
#initialize(post) ⇒ SchemaOrgBlogPostingPostSerializer
constructor
Public: Initializes the serializer with a post.
-
#serialize ⇒ Object
Serializes a post for the Schema.org Event type.
Constructor Details
#initialize(post) ⇒ SchemaOrgBlogPostingPostSerializer
Public: Initializes the serializer with a post.
11 12 13 |
# File 'lib/decidim/blogs/schema_org_blog_posting_post_serializer.rb', line 11 def initialize(post) @post = post end |
Instance Method Details
#serialize ⇒ Object
Serializes a post for the Schema.org Event type
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/decidim/blogs/schema_org_blog_posting_post_serializer.rb', line 19 def serialize attributes = { "@context": "https://schema.org", "@type": "BlogPosting", headline: decidim_escape_translated(post.title), author: } attributes = attributes.merge(image:) if post.photos.any? attributes = attributes.merge(datePublished: published) if post.published? attributes end |