Skip to content

Commit

Permalink
fix(#110): handle multiple video tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas COUTIN committed Jan 11, 2019
1 parent 15cf8fd commit b6829a6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/sitemap-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ class SitemapItem {
videoxml.element('video:family_friendly', video.family_friendly)
}
if (video.tag) {
videoxml.element('video:tag', video.tag)
if (typeof video.tag.length === 'undefined') {
videoxml.element('video:tag', video.tag)
} else {
for (const tag of video.tag) {
videoxml.element('video:tag', tag)
}
}
}
if (video.category) {
videoxml.element('video:category', video.category)
Expand Down
25 changes: 25 additions & 0 deletions tests/sitemap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,31 @@ describe('sitemapItem', () => {
expect(result).toBe(expectedResult)
})

it('supports array of tags', () => {
testvideo.video.tag = ['steak', 'fries']
var smap = new sm.SitemapItem(testvideo)

var result = smap.toString()
var expectedResult = '<url>' +
'<loc>https://roosterteeth.com/episode/achievement-hunter-achievement-hunter-burnout-paradise-millionaires-club</loc>' +
'<video:video>' +
thumbnailLoc +
title +
description +
playerLoc +
duration +
publicationDate +
'<video:tag>steak</video:tag><video:tag>fries</video:tag>' +
restriction +
galleryLoc +
price +
requiresSubscription +
platform +
'</video:video>' +
'</url>'
expect(result).toBe(expectedResult)
})

it('supports category', () => {
testvideo.video.category = 'Baking'
var smap = new sm.SitemapItem(testvideo)
Expand Down

0 comments on commit b6829a6

Please sign in to comment.