<commit_before>hexo.extend.generator.register('json-feed', hexo_generator_json_feed);

function hexo_generator_json_feed(site) {
	var cfg = hexo.config.hasOwnProperty('jsonFeed') ? hexo.config.jsonFeed : {},
	
		stripe = function (str) {
			return str.replace(/(<([^>]+)>)/ig, '');
		},

		minify = function (str) {
			return str.trim().replace(/\n/g, ' ').replace(/\s+/g, ' ');
		},
		
		posts = site.posts.sort('-date').filter(function (post) {
      return post.published;
    }).slice(0, cfg.limit || 25).map(function (post) {
      return {
        title: post.title,
        link: post.link,
				description: post.excerpt ? stripe(post.excerpt) : minify(stripe(post.content)),
				pubDate: post.date.toDate().toUTCString(),
				guid: post.permalink,
				category: post.categories.length ? post.categories.map(function (cat) {
          return cat.name;
        }).join(',') : post.tags.map(function (tag) {
          return tag.name;
        }).join(',')
      };
    }),
		
		rss = {
			title: hexo.config.title,
			description: hexo.config.description,
			language: hexo.config.language,
			link: hexo.config.url,
			pubDate: posts.length ? posts[0].pubDate : new Date().toUTCString(),
			lastBuildDate: new Date().toUTCString(),
			generator: 'hexo-generator-json-feed',
			webMaster: hexo.config.author,
			items: posts
		};
		
		return {
			path: 'feed.json',
			data: JSON.stringify(rss)
		};
}<commit_msg>Little updates for optimization<commit_after>hexo.extend.generator.register('json-feed', hexo_generator_json_feed);

function hexo_generator_json_feed(site) {
	var cfg = hexo.config.hasOwnProperty('jsonFeed') ? hexo.config.jsonFeed : {},

		stripe = function (str) {
			return str.replace(/(<([^>]+)>)/g, '');
		},

		minify = function (str) {
			return stripe(str).trim().replace(/\n/g, ' ').replace(/\s+/g, ' ');
		},

		posts = site.posts.sort('-date').filter(function (post) {
      return post.published;
    }).slice(0, cfg.limit || 25).map(function (post) {
      return {
        title: post.title,
        link: post.link,
				description: post.excerpt ? minify(post.excerpt) : minify(post.content),
				pubDate: post.date.toDate().toUTCString(),
				guid: post.permalink,
				category: post.categories.length ? post.categories.map(function (cat) {
          return cat.name;
        }).join(',') : post.tags.map(function (tag) {
          return tag.name;
        }).join(',')
      };
    }),

		build = new Date().toUTCString(),

		rss = {
			title: hexo.config.title,
			description: hexo.config.description,
			language: hexo.config.language,
			link: hexo.config.url,
			pubDate: posts.length ? posts[0].pubDate : build,
			lastBuildDate: build,
			generator: 'hexo-generator-json-feed',
			webMaster: hexo.config.author,
			items: posts
		};

		return {
			path: 'feed.json',
			data: JSON.stringify(rss)
		};
}
{'fraction_non_alphanumeric': 0.17680140597539543, 'fraction_numerical': 0.00281195079086116, 'mean_word_length': 3.0949640287769786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '1703777', 'n_tokens_mistral': 1085, 'n_tokens_neox': 960, 'n_words': 166}