page_structured_data 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8252e9dc643ed3ef13a551795d9ec1fdaad5958054207c45909adea2160ec429
4
- data.tar.gz: 894aa860c2de9cee51a4816381a0aadce901a0ddfaf37437c094a50f57162524
3
+ metadata.gz: caecea8674b2a1a804c733ede3c83657d96cc2eabf8f58b46a433a4d7e43b731
4
+ data.tar.gz: b53f5785a48de2835d11c21128e040aa738cb155053e23470dc37062c3181cc4
5
5
  SHA512:
6
- metadata.gz: d09cd884d324f2146835e4d5118ed705167c07a07336871be62f031775373c22f25cd60735e0cc156b372f196e08d43bb5be01a2d5eb5c5d4f27a8bacf8f2f75
7
- data.tar.gz: 34af579eb34c31d44e8b93c048ef3ac5781f7323158571ccd6fab50071a88f132d142aef434917e1ce4c65a35322e5794b6b0e15ac572e7f96de781a9c98cce7
6
+ metadata.gz: 81d9c8f0d0cd138c6a0d1e295e08784de43d0162fb772ac7183bf1001f20228dfdaf2044f6cac9a5c6883a475c019742a54aed9972dc35d893260b65f01ca935
7
+ data.tar.gz: 5e5cf941f5fc7c1e70596a0880516fdd2d209f2adc65de61c914063793eb3f50eba8ecc673c653c3d52efc9e1c270160318f2a9ab521cc8c89c59333a814c790
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PageStructuredData
4
+ module PageTypes
5
+ # Basic page metadata for any page
6
+ class BlogPosting
7
+ attr_reader :headline, :images, :published_at, :updated_at, :authors
8
+
9
+ def initialize(headline:, published_at:, updated_at:, images: [], authors: [])
10
+ @headline = headline
11
+ @images = images
12
+ @published_at = published_at
13
+ @updated_at = updated_at
14
+ @authors = authors
15
+ end
16
+
17
+ def json_ld # rubocop:disable Metrics/MethodLength
18
+ node = {
19
+ '@context': 'https://schema.org',
20
+ '@type': 'BlogPosting',
21
+ }
22
+
23
+ node[:headline] = headline
24
+ node[:image] = images
25
+ node[:datePublished] = published_at
26
+ node[:dateModified] = updated_at
27
+
28
+ author_hash = authors.map do |author|
29
+ {
30
+ '@type': 'Person',
31
+ name: author[:name],
32
+ url: author[:url],
33
+ }
34
+ end
35
+
36
+ node[:author] = author_hash
37
+
38
+ %(
39
+ <script type="application/ld+json">
40
+ #{node.to_json}
41
+ </script>
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module PageStructuredData
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_structured_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jey Geethan
@@ -60,6 +60,7 @@ files:
60
60
  - app/src/page_structured_data/anchors.rb
61
61
  - app/src/page_structured_data/breadcrumbs.rb
62
62
  - app/src/page_structured_data/page.rb
63
+ - app/src/page_structured_data/page_types/blog_posting.rb
63
64
  - app/src/page_structured_data/page_types/news_article.rb
64
65
  - app/views/layouts/page_structured_data/application.html.erb
65
66
  - app/views/page_structured_data/_meta_tags.html.slim