-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate feeds by categories? #3
Comments
Any update on it? |
It seems that somebody have to write one and push the commit by itself if it want... |
I would also like to have a feed based on either a category or a tag. |
I really want this feature at least for category . |
I found the hexo-generator-category-feed, but don't worked here with Hexo 3.0.1. Any idea? |
The hexo-generator-category-feed is not compatible with Hexo 3.x. I forked it and made some changes. Now it works for me with Hexo 3.x. See https://github.com/zklhp/hexo-generator-category-feed. |
@zklhp you can add this to the site~ |
Wouldn't something like diff -up hexo-generator-feed/lib/generator.js.noCat hexo-generator-feed/lib/generator.js
--- hexo-generator-feed/lib/generator.js.noCat 2015-06-22 00:53:57.252358394 +0200
+++ hexo-generator-feed/lib/generator.js 2015-06-22 00:55:27.556153242 +0200
@@ -15,10 +15,18 @@ module.exports = function(locals){
var config = this.config;
var feedConfig = config.feed;
var template = feedConfig.type === 'rss2' ? rss2Tmpl : atomTmpl;
+ var posts;
- var posts = locals.posts.sort('-date');
- if (feedConfig.limit) posts = posts.limit(feedConfig.limit);
+ if (feedConfig.category) {
+ posts = locals.posts.categories('politics').sort('-date');
+ }
+ else {
+ posts = locals.posts.sort('-date');
+ }
+ if (feedConfig.limit) {
+ posts = posts.limit(feedConfig.limit);
+ }
var xml = template({
config: config, work? |
@mcepl The code seems okay. And I modified a bit: diff -up hexo-generator-feed/lib/generator.js.noCat hexo-generator-feed/lib/generator.js
--- hexo-generator-feed/lib/generator.js.noCat 2015-06-22 00:53:57.252358394 +0200
+++ hexo-generator-feed/lib/generator.js 2015-06-22 00:55:27.556153242 +0200
@@ -15,10 +15,18 @@ module.exports = function(locals){
var config = this.config;
var feedConfig = config.feed;
var template = feedConfig.type === 'rss2' ? rss2Tmpl : atomTmpl;
- var posts = locals.posts.sort('-date');
+ var posts = locals.posts;
+ if (feedConfig.category) {
+ posts = posts.categories('politics');
+ }
+ posts = posts.sort('-date');
- if (feedConfig.limit) posts = posts.limit(feedConfig.limit);
+ if (feedConfig.limit) {
+ posts = posts.limit(feedConfig.limit);
+ }
var xml = template({
config: config, |
Sorry, after hexojs/hexo#1494 I gave up on hexo and switched to pelican. I am in the end a Python programmer really, and apparently when desiring The change above is thus now in public domain, and you can do whatever you want to do with it. |
Okay. Sorry Hexo didn't work out for you. |
In addition to the whole website, if it possible to generate separate feeds by different categories? Like WP: http://codex.wordpress.org/WordPress_Feeds
The text was updated successfully, but these errors were encountered: