index.js 684 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* global hexo */
  2. 'use strict';
  3. var assign = require('object-assign');
  4. var pathFn = require('path');
  5. var config = hexo.config.feed = assign({
  6. type: 'atom',
  7. limit: 20,
  8. hub: '',
  9. content: true,
  10. content_limit: 140,
  11. content_limit_delim: ''
  12. }, hexo.config.feed);
  13. var type = config.type.toLowerCase();
  14. // Check feed type
  15. if (type !== 'atom' && type !== 'rss2') {
  16. config.type = 'atom';
  17. } else {
  18. config.type = type;
  19. }
  20. // Set default feed path
  21. if (!config.path) {
  22. config.path = config.type + '.xml';
  23. }
  24. // Add extension name if don't have
  25. if (!pathFn.extname(config.path)) {
  26. config.path += '.xml';
  27. }
  28. hexo.extend.generator.register('feed', require('./lib/generator'));