page_structured_data 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9000350b01cd984cc3a81aba170b9afcf7a53793f750b7f532185832faba199e
4
- data.tar.gz: 9bdfb9ebba8878118a646825c0e06f8050846a00786b54aff20c1f03f96f02dd
3
+ metadata.gz: de6dfe0bcc4ddffd85f8b77498c1f4a34fcbdcd839cb362118033531ec1e7d48
4
+ data.tar.gz: 9152005a24c5e16562c3d38e285c9dc4a56803563c0387cad15beca54f646fda
5
5
  SHA512:
6
- metadata.gz: 9255931886ad66d7f2ee9769d31dfffd9dbe31f67ccece76292631be37c4596163d037591e5a6b0b4313474a435fcf2987c199aec2977590ac291556ff4cb4b3
7
- data.tar.gz: c3e348bf9504483ab32a9819b2ab1f5b9d93a5e5e24305199171d9e29477ce56242cec8c3b31cf82a404403805c2d2f63d94025b9b8aacee5064a3b5453f748c
6
+ metadata.gz: 41ca7bfed324d9e746c2e60cf092af955f11b1136ba4db2a4ef965babcd22870b4bfb5c1808d4fde1b2e53cfefe6dd664adfe2a41cc4ae44e6ecf809bf42b4dc
7
+ data.tar.gz: d53a5eb7986394deeaff433d74022b1d830bca59b9b9aaa2161e773e6010a6f7ba9802bd1662417c3be8729dfb0139239047766cca15bef39bf8569e8edf468a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project are documented here.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 1.0.8 - 2026-05-06
8
+
9
+ - Add `PageStructuredData::PageTypes::Organization` for schema.org Organization JSON-LD.
10
+
7
11
  ## 1.0.7 - 2026-05-06
8
12
 
9
13
  - Remove unused generated Rails engine boilerplate files.
data/README.md CHANGED
@@ -14,6 +14,7 @@ It helps Rails applications render:
14
14
  - Google-compatible JSON-LD structured data
15
15
  - Breadcrumb structured data
16
16
  - Article structured data for `BlogPosting` and `NewsArticle`
17
+ - Organization structured data
17
18
 
18
19
  ## Requirements
19
20
 
@@ -138,6 +139,7 @@ PageStructuredData includes page types for:
138
139
 
139
140
  - [`BlogPosting`](https://schema.org/BlogPosting)
140
141
  - [`NewsArticle`](https://schema.org/NewsArticle)
142
+ - [`Organization`](https://schema.org/Organization)
141
143
 
142
144
  Use a page type when the current page represents an article:
143
145
 
@@ -168,6 +170,27 @@ article_page_type = PageStructuredData::PageTypes::BlogPosting.new(
168
170
 
169
171
  For news pages, use `PageStructuredData::PageTypes::NewsArticle` with the same arguments.
170
172
 
173
+ Use `Organization` when the current page represents an organization:
174
+
175
+ ```ruby
176
+ organization_page_type = PageStructuredData::PageTypes::Organization.new(
177
+ name: "RocketApex",
178
+ url: "https://rocketapex.com",
179
+ logo: "https://rocketapex.com/logo.png",
180
+ same_as: ["https://github.com/RocketApex"],
181
+ parent_organization: {
182
+ name: "Parent Org",
183
+ url: "https://parent.example"
184
+ }
185
+ )
186
+
187
+ @page_meta = PageStructuredData::Page.new(
188
+ title: "About RocketApex",
189
+ description: "Open source projects from RocketApex",
190
+ page_type: organization_page_type
191
+ )
192
+ ```
193
+
171
194
  ## API Reference
172
195
 
173
196
  ### `PageStructuredData::Page`
@@ -233,6 +256,24 @@ Important methods:
233
256
  - `to_h`: returns a structured hash for article JSON-LD.
234
257
  - `json_ld`: returns an article JSON-LD script tag.
235
258
 
259
+ ### Organization Page Type
260
+
261
+ ```ruby
262
+ PageStructuredData::PageTypes::Organization.new(
263
+ name:,
264
+ url:,
265
+ logo: nil,
266
+ same_as: [],
267
+ parent_organization: nil
268
+ )
269
+ ```
270
+
271
+ `parent_organization` should be a hash with `:name` and `:url` keys.
272
+
273
+ Important methods:
274
+
275
+ - `json_ld`: returns an organization JSON-LD script tag.
276
+
236
277
  ## Development
237
278
 
238
279
  Run the test suite:
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PageStructuredData
4
+ module PageTypes
5
+ # Organization structured data for a page
6
+ class Organization
7
+ attr_reader :name, :url, :logo, :same_as, :parent_organization
8
+
9
+ def initialize(name:, url:, logo: nil, same_as: [], parent_organization: nil)
10
+ @name = name
11
+ @url = url
12
+ @logo = logo
13
+ @same_as = same_as
14
+ @parent_organization = parent_organization
15
+ end
16
+
17
+ def json_ld # rubocop:disable Metrics/MethodLength
18
+ node = {
19
+ '@context': 'https://schema.org',
20
+ '@type': 'Organization',
21
+ }
22
+
23
+ node[:name] = name
24
+ node[:url] = url
25
+ node[:logo] = logo if logo.present?
26
+ node[:sameAs] = same_as if same_as.present?
27
+
28
+ if parent_organization.present?
29
+ node[:parentOrganization] = {
30
+ '@type': 'Organization',
31
+ name: parent_organization[:name],
32
+ url: parent_organization[:url],
33
+ }
34
+ end
35
+
36
+ %(
37
+ <script type="application/ld+json">
38
+ #{node.to_json}
39
+ </script>
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module PageStructuredData
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -1,5 +1,12 @@
1
1
  require "page_structured_data/version"
2
2
  require "page_structured_data/engine"
3
+ require_relative "../app/src/page_structured_data/anchors"
4
+ require_relative "../app/src/page_structured_data/breadcrumbs"
5
+ require_relative "../app/src/page_structured_data/page_types/article"
6
+ require_relative "../app/src/page_structured_data/page_types/blog_posting"
7
+ require_relative "../app/src/page_structured_data/page_types/news_article"
8
+ require_relative "../app/src/page_structured_data/page_types/organization"
9
+ require_relative "../app/src/page_structured_data/page"
3
10
 
4
11
  module PageStructuredData
5
12
  class << self
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: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jey Geethan
@@ -49,6 +49,7 @@ files:
49
49
  - app/src/page_structured_data/page_types/article.rb
50
50
  - app/src/page_structured_data/page_types/blog_posting.rb
51
51
  - app/src/page_structured_data/page_types/news_article.rb
52
+ - app/src/page_structured_data/page_types/organization.rb
52
53
  - app/views/page_structured_data/_meta_tags.html.erb
53
54
  - config/routes.rb
54
55
  - lib/page_structured_data.rb