<commit_before>var fs = require('fs');
var path = require('path');
var url = require('url');
var sm = require('sitemap');

var urls = [];

module.exports = {
    hooks: {
        // Index page
        "page": function(page) {
            urls.push({
                url: this.contentPath(page.path)
            });

            return page;
        },

        // Write sitemap.xml
        "finish": function() {
            if (!this.config.options.pluginsConfig.sitemap
            || !this.config.options.pluginsConfig.sitemap.hostname) {
                throw "Need a 'hostname' configuration for sitemap generation";
            }

            var sitemap = sm.createSitemap({
                cacheTime: 600000,
                hostname: url.resolve(this.config.options.pluginsConfig.sitemap.hostname, '/'),
                urls: urls
            });

            var xml = sitemap.toString();
            fs.writeFileSync(
                path.resolve(this.options.output, 'sitemap.xml'),
                xml
            );
        }
    }
};<commit_msg>Only build sitemap for website<commit_after>var fs = require('fs');
var path = require('path');
var url = require('url');
var sm = require('sitemap');

var urls = [];

module.exports = {
    hooks: {
        // Index page
        "page": function(page) {
            if (this.options.generator == 'website') {
                urls.push({
                    url: this.contentPath(page.path)
                });
            }

            return page;
        },

        // Write sitemap.xml
        "finish": function() {
            if (this.options.generator != 'website') return;
            if (!this.config.options.pluginsConfig.sitemap
            || !this.config.options.pluginsConfig.sitemap.hostname) {
                throw "Need a 'hostname' configuration for sitemap generation";
            }

            var sitemap = sm.createSitemap({
                cacheTime: 600000,
                hostname: url.resolve(this.config.options.pluginsConfig.sitemap.hostname, '/'),
                urls: urls
            });

            var xml = sitemap.toString();
            fs.writeFileSync(
                path.resolve(this.options.output, 'sitemap.xml'),
                xml
            );
        }
    }
};
{'fraction_non_alphanumeric': 0.12768758227292673, 'fraction_numerical': 0.005265467310223783, 'mean_word_length': 1.5165562913907285, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4162489', 'n_tokens_mistral': 651, 'n_tokens_neox': 622, 'n_words': 123}