docs: function plugin(opts){
    /**
     * Init
     */
    opts = opts || {};
  
    // Accept string option to specify the hostname
    if (typeof opts === 'string') {
      opts = { hostname: opts };
    }
  
    // A hostname should be specified
    if (!opts.hostname) {
      throw new Error('"hostname" option required');
    }
  
    // Map options to local variables and set defaults
    var changefreq = opts.changefreq;
    var hostname = opts.hostname;
    var lastmod = opts.lastmod;
    var links = opts.links;
    var omitExtension = opts.omitExtension;
    var omitIndex = opts.omitIndex;
    var output = opts.output || 'sitemap.xml';
    var pattern = opts.pattern || '**/*.html';
    var priority = opts.priority;
    var urlProperty = opts.urlProperty || 'canonical';
    var modifiedProperty = opts.modifiedProperty || 'lastmod';
    var privateProperty = opts.privateProperty || 'private';
    var priorityProperty = opts.priorityProperty || 'priority'; 
  
    /**
     * Main plugin function
     */
    return function(files, metalsmith, done) {
      // Create sitemap object
      var sitemap = sm.createSitemap ({
        hostname: hostname
      });
  
      // Checks whether files should be processed
      function check(file, frontmatter) {
        // Only process files that match the pattern
        if (!match(file, pattern)[0]) {
          return false;
        }
  
        // Don't process private files
        if (get(frontmatter, privateProperty)) {
          return false;
        }
  
        return true;
      }
  
      // Builds a url
      function buildUrl(file, frontmatter) {
        // Frontmatter settings take precedence
        var canonicalUrl = get(frontmatter, urlProperty);
        if (is.string(canonicalUrl)) {
          return canonicalUrl;
        }
  
        // Remove index.html if necessary
        var indexFile = 'index.html';
        if (omitIndex && path.basename(file) === indexFile) {
          return replaceBackslash(file.slice(0, 0 - indexFile.length));
        }
  
        // Remove extension if necessary
        if (omitExtension) {
          return replaceBackslash(file.slice(0, 0 - path.extname(file).length));
        }
  
        // Otherwise just use 'file'
        return replaceBackslash(file);
      }
  
      function replaceBackslash(url) {
        return url.replace(/\\/g, '/');
      }
  
      Object.keys(files).forEach(function(file) {
        // Get the current file's frontmatter
        var frontmatter = files[file];
  
        // Only process files that pass the check
        if (!check(file, frontmatter)) {
          return;
        }
  
        // Create the sitemap entry (reject keys with falsy values)
        var entry = pick({
          changefreq: frontmatter.changefreq || changefreq,
          priority: get(frontmatter, priorityProperty) || priority,
          lastmod: get(frontmatter, modifiedProperty) || lastmod,
          links: get(frontmatter, links)
        }, identity);
  
        // Add the url (which is allowed to be falsy)
        entry.url = buildUrl(file, frontmatter);
  
        // Add the entry to the sitemap
        sitemap.add(entry);
      });
  
      // Create sitemap in files
      files[output] = {
        contents: new Buffer(sitemap.toString())
      };
  
      done();
    };
  }