Skip to content

Latest commit

 

History

History
298 lines (186 loc) · 4.91 KB

docs.md

File metadata and controls

298 lines (186 loc) · 4.91 KB

Table of Contents

xmlParse

Sitemap Parser

Copyright (c) 2020 Sean Thomas Burke Licensed under the MIT license.

Meta

  • author: Sean Burke <@seantomburke>

SitesArray

An array of urls

Type: Array<String>

Examples

[
  'www.google.com',
  'https://www.linkedin.com'
]

SitesData

Resolve handler type for the promise in this.parse()

Type: Object

Properties

Examples

{
  url: 'https://linkedin.com/sitemap.xml',
  sites: [
    'https://linkedin.com/project1',
    'https://linkedin.com/project2'
  ]
}

ParseData

Resolve handler type for the promise in this.parse()

Type: Object

Properties

  • error Error that either comes from xmlParse or request or custom error
  • data Object
    • data.url string URL of sitemap
    • data.urlset Array Array of returned URLs
      • data.urlset.url string single Url
    • data.sitemapindex Object index of sitemap
      • data.sitemapindex.sitemap string Sitemap

Examples

{
  error: "There was an error!"
  data: {
    url: 'https://linkedin.com',
    urlset: [{
      url: 'https://www.linkedin.com/project1'
    },[{
      url: 'https://www.linkedin.com/project2'
    }]
  }
}

Timeout

Timeout in milliseconds

Type: Number

getSitesCallback

Callback for the getSites method

Type: Function

Parameters

  • error Object error from callback
  • sites Array an Array of sitemaps

Sitemapper

Type: Object

fetch

Gets the sites from a sitemap.xml with a given URL

Parameters

Examples

sitemapper.fetch('example.xml')
 .then((sites) => console.log(sites));

Returns Promise<SitesData>

getSites

/** Gets the sites from a sitemap.xml with a given URL

Type: Function

Parameters

Meta

  • deprecated: This is deprecated.

timeout

Get the timeout

Examples

console.log(sitemapper.timeout);

Returns Timeout

timeout

Set the timeout

Parameters

Examples

sitemapper.timeout = 15000; // 15 seconds

url

Parameters

  • url string url for making requests. Should be a link to a sitemaps.xml

Examples

sitemapper.url = 'https://wp.seantburke.com/sitemap.xml'

url

Get the url to parse

Examples

console.log(sitemapper.url)

Returns string