sitemap-javascript
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -258,2 +258,20 @@ "use strict"; | ||
}); | ||
// Address handling | ||
item.address.forEach((address) => { | ||
this.push((0, sitemap_xml_1.otag)(types_1.TagNames['address:address'])); | ||
this.push((0, sitemap_xml_1.element)(types_1.TagNames['address:loc'], address.address)); | ||
if (address.city) { | ||
this.push((0, sitemap_xml_1.element)(types_1.TagNames['address:city'], address.city)); | ||
} | ||
if (address.region) { | ||
this.push((0, sitemap_xml_1.element)(types_1.TagNames['address:region'], address.region)); | ||
} | ||
if (address.postal_code) { | ||
this.push((0, sitemap_xml_1.element)(types_1.TagNames['address:postal_code'], address.postal_code)); | ||
} | ||
if (address.country) { | ||
this.push((0, sitemap_xml_1.element)(types_1.TagNames['address:country'], address.country)); | ||
} | ||
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames['address:address'])); | ||
}); | ||
this.push((0, sitemap_xml_1.ctag)(types_1.TagNames.url)); | ||
@@ -260,0 +278,0 @@ callback(); |
@@ -17,2 +17,3 @@ "use strict"; | ||
img: [], | ||
address: [], | ||
video: [], | ||
@@ -34,2 +35,5 @@ links: [], | ||
}; | ||
const addressTemplate = { | ||
address: '', | ||
}; | ||
const linkTemplate = { | ||
@@ -79,2 +83,3 @@ lang: '', | ||
let currentImage = { ...imageTemplate }; | ||
let currentAddress = { ...addressTemplate }; | ||
let currentLink = { ...linkTemplate }; | ||
@@ -211,2 +216,17 @@ let dontpushCurrentLink = false; | ||
break; | ||
case types_1.TagNames['address:address']: | ||
currentImage.url = text; | ||
break; | ||
case types_1.TagNames['address:city']: | ||
currentImage.url = text; | ||
break; | ||
case types_1.TagNames['address:region']: | ||
currentImage.url = text; | ||
break; | ||
case types_1.TagNames['address:postal_code']: | ||
currentImage.url = text; | ||
break; | ||
case types_1.TagNames['address:country']: | ||
currentImage.url = text; | ||
break; | ||
case types_1.TagNames['news:access']: | ||
@@ -418,2 +438,6 @@ if (!currentItem.news) { | ||
break; | ||
case types_1.TagNames['address:address']: | ||
currentItem.address.push(currentAddress); | ||
currentAddress = { ...addressTemplate }; | ||
break; | ||
case types_1.TagNames['xhtml:link']: | ||
@@ -420,0 +444,0 @@ if (!dontpushCurrentLink) { |
@@ -10,2 +10,3 @@ /// <reference types="node" /> | ||
image: boolean; | ||
address: boolean; | ||
custom?: string[]; | ||
@@ -12,0 +13,0 @@ } |
@@ -22,3 +22,3 @@ "use strict"; | ||
if (news) { | ||
ns += ' xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"'; | ||
ns += ' xmlns:news="http://www.google.com/schemas/news/0.9"'; | ||
} | ||
@@ -29,6 +29,6 @@ if (xhtml) { | ||
if (image) { | ||
ns += ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'; | ||
ns += ' xmlns:image="http://www.google.com/schemas/image/1.1"'; | ||
} | ||
if (video) { | ||
ns += ' xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"'; | ||
ns += ' xmlns:video="http://www.google.com/schemas/video/1.1"'; | ||
} | ||
@@ -46,2 +46,3 @@ if (custom) { | ||
video: true, | ||
address: true, | ||
}; | ||
@@ -48,0 +49,0 @@ const defaultStreamOpts = { |
@@ -107,2 +107,29 @@ /// <reference types="node" /> | ||
} | ||
export interface Address { | ||
/** | ||
* The URL of the image | ||
* @example 'https://example.com/image.jpg' | ||
*/ | ||
address: string; | ||
/** | ||
* The caption of the image | ||
* @example 'Thanksgiving dinner' | ||
*/ | ||
city?: string; | ||
/** | ||
* The title of the image | ||
* @example 'Star Wars EP IV' | ||
*/ | ||
region?: string; | ||
/** | ||
* The geographic location of the image. | ||
* @example 'Limerick, Ireland' | ||
*/ | ||
postal_code?: string; | ||
/** | ||
* A URL to the license of the image. | ||
* @example 'https://example.com/license.txt' | ||
*/ | ||
country?: string; | ||
} | ||
interface VideoItemBase { | ||
@@ -329,2 +356,3 @@ /** | ||
img: Img[]; | ||
address: Address[]; | ||
video: VideoItem[]; | ||
@@ -339,2 +367,3 @@ links: LinkItem[]; | ||
img?: string | Img | (string | Img)[]; | ||
address?: string | Address | (string | Address)[]; | ||
links?: LinkItem[]; | ||
@@ -392,2 +421,8 @@ lastmodfile?: string | Buffer | URL; | ||
versionDescription = "versionDescription", | ||
'address:loc' = "address:loc", | ||
'address:address' = "address:address", | ||
'address:city' = "address:city", | ||
'address:region' = "address:region", | ||
'address:postal_code' = "address:postal_code", | ||
'address:country' = "address:country", | ||
'video:thumbnail_loc' = "video:thumbnail_loc", | ||
@@ -394,0 +429,0 @@ 'video:video' = "video:video", |
@@ -117,2 +117,8 @@ "use strict"; | ||
TagNames["versionDescription"] = "versionDescription"; | ||
TagNames["address:loc"] = "address:loc"; | ||
TagNames["address:address"] = "address:address"; | ||
TagNames["address:city"] = "address:city"; | ||
TagNames["address:region"] = "address:region"; | ||
TagNames["address:postal_code"] = "address:postal_code"; | ||
TagNames["address:country"] = "address:country"; | ||
TagNames["video:thumbnail_loc"] = "video:thumbnail_loc"; | ||
@@ -119,0 +125,0 @@ TagNames["video:video"] = "video:video"; |
@@ -261,2 +261,3 @@ "use strict"; | ||
let smi = { | ||
address: [], | ||
img: [], | ||
@@ -276,2 +277,24 @@ video: [], | ||
smi.url = new url_1.URL(smiLoose.url, hostname).toString(); | ||
/*let address: Address[] = []; | ||
if (smiLoose.address) { | ||
if (typeof smiLoose.address === 'string') { | ||
// string -> array of objects | ||
smiLoose.address = [{ url: smiLoose.address }]; | ||
} else if (!Array.isArray(smiLoose.address)) { | ||
// object -> array of objects | ||
smiLoose.address = [smiLoose.address]; | ||
} | ||
address = smiLoose.address.map( | ||
(el): Address => (typeof el === 'string' ? { url: el } : el) | ||
); | ||
} | ||
// prepend hostname to all image urls | ||
smi.address = address.map( | ||
(el: Address): Address => ({ | ||
...el, | ||
url: new URL(el.url, hostname).toString(), | ||
}) | ||
); | ||
*/ | ||
let img = []; | ||
@@ -278,0 +301,0 @@ if (smiLoose.img) { |
{ | ||
"name": "sitemap-javascript", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Sitemap-generating lib/cli", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174086
3289