Skip to content

Commit 931cf76

Browse files
committed
Add support for author tag parsing
Addresses feature request in #171
1 parent 414133c commit 931cf76

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface ILinkPreviewResponse {
66
url: string;
77
title: string;
88
siteName: string | undefined;
9+
author: string | undefined;
910
description: string | undefined;
1011
mediaType: string;
1112
contentType: string | undefined;
@@ -74,6 +75,13 @@ function getSiteName(doc: cheerio.Root) {
7475
return siteName;
7576
}
7677

78+
function getAuthor(doc: cheerio.Root) {
79+
const author =
80+
metaTagContent(doc, `author`, `name`) ||
81+
metaTagContent(doc, `article:author`, `property`);
82+
return author;
83+
}
84+
7785
function getDescription(doc: cheerio.Root) {
7886
const description =
7987
metaTagContent(doc, `description`, `name`) ||
@@ -301,6 +309,7 @@ function parseTextResponse(
301309
title: getTitle(doc),
302310
siteName: getSiteName(doc),
303311
description: getDescription(doc),
312+
author: getAuthor(doc),
304313
mediaType: getMediaType(doc) || `website`,
305314
contentType,
306315
images: getImages(doc, url, options.imagesPropertyType),

0 commit comments

Comments
 (0)