Skip to content

Commit

Permalink
feat: add support for 'author' meta tag (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuji44 committed Jul 21, 2021
1 parent 4b6e032 commit 9320aa1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ function getMetadata (ctx, opts: Opts) {
if (tagname === 'meta') {
if (attribs.name === 'description' && attribs.content) {
pair = ['description', attribs.content]
} else if (attribs.name === 'author' && attribs.content) {
pair = ['author', attribs.content]
} else if (attribs.name === 'keywords' && attribs.content) {
let keywords = attribs.content
.replace(/^[,\s]{1,}|[,\s]{1,}$/g, '') // gets rid of trailing space or sommas
Expand Down
1 change: 1 addition & 0 deletions test/basic/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<title>ccc</title>
<meta name="author" content="abc" />
<meta name="description" content="aaa" />
<meta name="keywords" content="a, b, c" />
</head>
Expand Down
2 changes: 2 additions & 0 deletions test/basic/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test('should detect title, description and keywords', async () => {

const expected = {
favicon: 'http://localhost/favicon.ico',
author: 'abc',
description: 'aaa',
keywords: ['a', 'b', 'c'],
title: 'ccc'
Expand Down Expand Up @@ -62,6 +63,7 @@ test('should detect title, description and keywords', async () => {

const expected = {
favicon: 'http://localhost/favicon.ico',
author: 'abc',
description: 'aaa',
keywords: ['a', 'b', 'c'],
title: 'ccc'
Expand Down

0 comments on commit 9320aa1

Please sign in to comment.