|
10 | 10 | def schema_json(answerCount)
|
11 | 11 | if answerCount > 0
|
12 | 12 | answer_json =
|
13 |
| - ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"dateCreated":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}"}}' % |
| 13 | + ',"acceptedAnswer":{"@type":"Answer","text":"%{answer_text}","upvoteCount":%{answer_likes},"datePublished":"%{answered_at}","url":"%{answer_url}","author":{"@type":"Person","name":"%{username2}","url":"%{user2_url}"}}' % |
14 | 14 | {
|
15 | 15 | answer_text: p2.excerpt,
|
16 | 16 | answer_likes: p2.like_count,
|
17 | 17 | answered_at: p2.created_at.as_json,
|
18 | 18 | answer_url: p2.full_url,
|
19 | 19 | username2: p2.user&.username,
|
| 20 | + user2_url: p2.user&.full_url, |
20 | 21 | }
|
21 | 22 | else
|
22 | 23 | answer_json = ""
|
23 | 24 | end
|
24 | 25 |
|
25 | 26 | # rubocop:todo Layout/LineLength
|
26 |
| - '<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"dateCreated":"%{created_at}","author":{"@type":"Person","name":"%{username1}"}%{answer_json}}}</script>' % |
| 27 | + '<script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"%{title}","mainEntity":{"@type":"Question","name":"%{title}","text":"%{question_text}","upvoteCount":%{question_likes},"answerCount":%{answerCount},"datePublished":"%{created_at}","author":{"@type":"Person","name":"%{username1}","url":"%{user1_url}"}%{answer_json}}}</script>' % |
27 | 28 | # rubocop:enable Layout/LineLength
|
28 | 29 | {
|
29 | 30 | title: topic.title,
|
30 | 31 | question_text: p1.excerpt,
|
31 | 32 | question_likes: p1.like_count,
|
32 | 33 | answerCount: answerCount,
|
33 | 34 | created_at: topic.created_at.as_json,
|
34 |
| - username1: topic.user&.name, |
| 35 | + username1: topic.user&.username, |
| 36 | + user1_url: topic.user&.full_url, |
35 | 37 | answer_json: answer_json,
|
36 | 38 | }
|
37 | 39 | end
|
|
0 commit comments