Add support for author array in JSON-LD. #617 (#618)

pull/619/head
Garrett Xu 4 years ago committed by GitHub
parent 3844d8f05b
commit 3fe82816af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1380,8 +1380,19 @@ Readability.prototype = {
} else if (typeof parsed.headline === "string") {
metadata.title = parsed.headline.trim();
}
if (parsed.author && typeof parsed.author.name === "string") {
metadata.byline = parsed.author.name.trim();
if (parsed.author) {
if (typeof parsed.author.name === "string") {
metadata.byline = parsed.author.name.trim();
} else if (Array.isArray(parsed.author) && parsed.author[0] && typeof parsed.author[0].name === "string") {
metadata.byline = parsed.author
.filter(function(author) {
return author && typeof author.name === "string";
})
.map(function(author) {
return author.name.trim();
})
.join(", ");
}
}
if (typeof parsed.description === "string") {
metadata.excerpt = parsed.description.trim();

@ -1,6 +1,6 @@
{
"title": "Facebook Is Tracking Me Even Though Im Not on Facebook",
"byline": "By Daniel Kahn Gillmor, Senior Staff Technologist, ACLU Speech, Privacy, and Technology Project",
"byline": "Daniel Kahn Gillmor",
"dir": "ltr",
"excerpt": "Facebook collects data about people who have never even opted in. But there are ways these non-users can protect themselves.",
"siteName": "American Civil Liberties Union",

@ -1,6 +1,6 @@
{
"title": "Tite diz que errou ao levar taça da Libertadores a Lula em 2012",
"byline": "21.dez.2018 às 10h55",
"byline": "Bruno (Henrique Zecchin) Rodrigues",
"dir": null,
"excerpt": "Na ocasião, técnico do Corinthians entregou réplica do troféu ao ex-presidente",
"siteName": "Folha de S.Paulo",

@ -1,6 +1,6 @@
{
"title": "Screenshot : «Vape Wave», «6 Days», «Alphonse Président»…",
"byline": "Par Alexandre Hervaud et Jérémy Piette",
"byline": "Alexandre Hervaud, Jérémy Piette",
"dir": null,
"excerpt": "Séries, documentaires, programmes jeunesse… Retrouvez les recommandations de Libération pour savoir quoi regarder sur vos écrans cette semaine.\nPour dépasser...",
"siteName": "Libération",

Loading…
Cancel
Save