File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ class JSONLDDrop < Jekyll::Drops::Drop
2121 private :logo
2222
2323 VALID_ENTITY_TYPES = %w( BlogPosting CreativeWork ) . freeze
24- private_constant :VALID_ENTITY_TYPES
24+ VALID_AUTHOR_TYPES = %w( Organization Person ) . freeze
25+ private_constant :VALID_ENTITY_TYPES , :VALID_AUTHOR_TYPES
2526
2627 # page_drop should be an instance of Jekyll::SeoTag::Drop
2728 def initialize ( page_drop )
@@ -38,8 +39,11 @@ def fallback_data
3839 def author
3940 return unless page_drop . author [ "name" ]
4041
42+ author_type = page_drop . author [ "type" ]
43+ return if author_type && !VALID_AUTHOR_TYPES . include? ( author_type )
44+
4145 {
42- "@type" => "Person" ,
46+ "@type" => author_type || "Person" ,
4347 "name" => page_drop . author [ "name" ] ,
4448 }
4549 end
Original file line number Diff line number Diff line change 7272 end
7373 end
7474 end
75+
76+ context "when type Organization" do
77+ let ( :author ) { { "name" => "organization" , "type" => "Organization" } }
78+
79+ it "returns the author with type" do
80+ expect ( subject ) . to have_key ( "author" )
81+ expect ( subject [ "author" ] ) . to be_a ( Hash )
82+ expect ( subject [ "author" ] ) . to have_key ( "@type" )
83+ expect ( subject [ "author" ] [ "@type" ] ) . to eql ( "Organization" )
84+ expect ( subject [ "author" ] ) . to have_key ( "name" )
85+ expect ( subject [ "author" ] [ "name" ] ) . to be_a ( String )
86+ expect ( subject [ "author" ] [ "name" ] ) . to eql ( "organization" )
87+ end
88+ end
89+
90+ context "when invalid type" do
91+ let ( :author ) { { "name" => "organization" , "type" => "Invalid" } }
92+
93+ it "returns the author with type" do
94+ expect ( subject ) . to have_key ( "author" )
95+ expect ( subject [ "author" ] ) . to be nil
96+ end
97+ end
7598 end
7699
77100 context "image" do
You can’t perform that action at this time.
0 commit comments