Skip to content

Commit

Permalink
:fix: 修复 rss 插件逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
zyao89 committed Jan 11, 2020
1 parent df929b8 commit ec46fe3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"moment": "^2.24.0",
"rss": "^1.2.2",
"svg-sprite-loader": "^4.1.6",
"svgo": "^1.3.2",
"svgo-loader": "^2.2.1",
Expand Down
14 changes: 7 additions & 7 deletions theme/plugins/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ module.exports = (options, ctx) => {
return !(home === true || title === undefined || isPrivate === true);
})
.filter(page => filter(page.frontmatter))
.map(page => ({ ...page, date: new Date(page.frontmatter.date || '') }))
.map(page => ({ ...page, date: new Date(page.frontmatter.date || page.birthTimestamp || '') }))
.sort((a, b) => b.date - a.date)
.map(page => {
logger.warn(page);
const frontmatter = page.frontmatter || {};
const categories = Array.isArray(frontmatter.categories) ? frontmatter.categories.join(',') : _.isString(frontmatter.categories) && frontmatter.categories || '';
const tags = Array.isArray(frontmatter.tags) ? frontmatter.tags.join(',') : _.isString(frontmatter.tags) && frontmatter.tags || '';
const categories = Array.isArray(frontmatter.categories) ? frontmatter.categories : _.isString(frontmatter.categories) && [ frontmatter.categories ];
const tags = Array.isArray(frontmatter.tags) ? frontmatter.tags : _.isString(frontmatter.tags) && [ frontmatter.tags ];
return {
title: page.title,
description: page.excerpt,
url: `${siteUrl}${page.path}`,
categories, tags,
url: `${siteUrl}${decodeURIComponent(page.path)}`,
guid: page.path,
categories: [].concat(categories, tags),
author: frontmatter.author || author,
date: frontmatter.dateFormat || page.date,
date: page.date,
};
})
.slice(0, count)
Expand Down

0 comments on commit ec46fe3

Please sign in to comment.