Class: Decidim::Blogs::SchemaOrgBlogPostingPostSerializer
- Inherits:
-
Exporters::Serializer
- Object
- Exporters::Serializer
- Decidim::Blogs::SchemaOrgBlogPostingPostSerializer
- Includes:
- ActionView::Helpers::UrlHelper, SanitizeHelper, TranslationsHelper
- Defined in:
- decidim-blogs/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.
Methods included from SanitizeHelper
#decidim_escape_translated, #decidim_html_escape, #decidim_rich_text, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_sanitize_translated, #decidim_url_escape, included
Methods included from TranslationsHelper
empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods inherited from Exporters::Serializer
Constructor Details
#initialize(post) ⇒ SchemaOrgBlogPostingPostSerializer
Public: Initializes the serializer with a post.
11 12 13 |
# File 'decidim-blogs/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 'decidim-blogs/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 |