diff --git a/plugin.rb b/plugin.rb index 78eb7f3..d0430ed 100644 --- a/plugin.rb +++ b/plugin.rb @@ -303,10 +303,11 @@ def before_head_close_meta(controller) "text" => get_schema_text(first_post), "upvoteCount" => first_post.like_count, "answerCount" => 0, - "dateCreated" => topic.created_at, + "datePublished" => topic.created_at, "author" => { "@type" => "Person", - "name" => topic.user&.name, + "name" => topic.user&.username, + "url" => topic.user&.full_url, }, } @@ -319,11 +320,12 @@ def before_head_close_meta(controller) "@type" => "Answer", "text" => get_schema_text(accepted_answer), "upvoteCount" => accepted_answer.like_count, - "dateCreated" => accepted_answer.created_at, + "datePublished" => accepted_answer.created_at, "url" => accepted_answer.full_url, "author" => { "@type" => "Person", "name" => accepted_answer.user&.username, + "url" => accepted_answer.user&.full_url, }, } else diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb index e2c1186..fc3841b 100644 --- a/spec/requests/topics_controller_spec.rb +++ b/spec/requests/topics_controller_spec.rb @@ -10,20 +10,21 @@ def schema_json(answerCount) if answerCount > 0 answer_json = - ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"dateCreated":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}"}}' % + ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"datePublished":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}","url":"%{user2_url}"}}' % { answer_text: p2.excerpt, answer_likes: p2.like_count, answered_at: p2.created_at.as_json, answer_url: p2.full_url, username2: p2.user&.username, + user2_url: p2.user&.full_url, } else answer_json = "" end # rubocop:todo Layout/LineLength - '' % + '' % # rubocop:enable Layout/LineLength { title: topic.title, @@ -31,7 +32,8 @@ def schema_json(answerCount) question_likes: p1.like_count, answerCount: answerCount, created_at: topic.created_at.as_json, - username1: topic.user&.name, + username1: topic.user&.username, + user1_url: topic.user&.full_url, answer_json: answer_json, } end