Skip to content

Commit

Permalink
Merge pull request #20 from auroral-ui/beta
Browse files Browse the repository at this point in the history
v1.8.4
  • Loading branch information
bennyxguo authored Nov 1, 2023
2 parents 22a561f + f3896cc commit 978cd9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 36 deletions.
58 changes: 27 additions & 31 deletions lib/generators/category.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
const pagination = require('hexo-pagination')
const {
categoryMapper,
categoryPageMapper,
postListMapper
} = require('../helpers/mapper')
const pagination = require('hexo-pagination');
const { categoryMapper, categoryPageMapper, postListMapper } = require('../helpers/mapper');

class CategoryGenerator {
data = []
posts = []
configs = {}
data = [];
posts = [];
configs = {};

constructor(categories, posts, configs) {
this.data = categories.length > 0 ? categories : []
this.posts = posts
this.configs = configs
this.reduceCategories()
for(let cat of this.data) {
this.data = categories.length > 0 ? categories : [];
this.posts = posts;
this.configs = configs;
this.reduceCategories();
for (let cat of this.data) {
cat.data.postlist.sort(function (a, b) {
return a.date< b.date? 1 : -1;
})
return a.date < b.date ? 1 : -1;
});
}
}

Expand All @@ -27,26 +23,26 @@ class CategoryGenerator {
data.push({
path: 'api/categories.json',
data: JSON.stringify([])
})
});
} else {
data.push({
path: 'api/categories.json',
data: JSON.stringify(this.data.map(categoryMapper))
})
const categoryPages = this.data.map(categoryPageMapper)
data = data.concat(categoryPages)
});
const categoryPages = this.data.map(categoryPageMapper);
data = data.concat(categoryPages);
}
return data
return data;
}

reduceCategories() {
if (this.count() <= 0) return
const categories = this.data
const posts = this.posts
const configs = this.configs
if (this.count() <= 0) return;
const categories = this.data;
const posts = this.posts;
const configs = this.configs;

this.data = categories.reduce(function (result, item) {
if (!item.length) return result
if (!item.length) return result;

return result.concat(
pagination(item.path, posts, {
Expand All @@ -57,17 +53,17 @@ class CategoryGenerator {
count: item.posts.length,
path: 'api/categories/' + item.slug + '.json',
postlist: item.posts.map((post) => {
return postListMapper(post, configs)
return postListMapper(post, configs);
})
}
})
)
}, [])
);
}, []);
}

count() {
return this.data.length
return this.data.length;
}
}

module.exports = CategoryGenerator
module.exports = CategoryGenerator;
6 changes: 3 additions & 3 deletions lib/generators/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class PostGenerator {
// To keep the list post count event, use 13 instead of 12
const pageSize = this.isFeature ? 12 : 13;
const pageCount = Math.ceil(length / pageSize);
const postData = filteredData.map(postListMapper);
const postData = filteredData.map((item) => postListMapper(item, this.configs));

for (let i = 0; i < length; i += pageSize) {
pageJson.push({
Expand Down Expand Up @@ -267,7 +267,7 @@ class PostGenerator {
// To keep the list post count event, use 13 instead of 12
const pageSize = this.isFeature ? 12 : 13;
const pageCount = Math.ceil(length / pageSize);
const postData = filteredData.map(postListMapper);
const postData = filteredData.map((item) => postListMapper(item, this.configs));

for (let i = 0; i < length; i += pageSize) {
pageJson.push({
Expand Down Expand Up @@ -313,7 +313,7 @@ class PostGenerator {
if (this.count() <= 0) return data;
data.push({
path: 'api/features.json',
data: JSON.stringify(this.features.map(postListMapper))
data: JSON.stringify(this.features.map((item) => postListMapper(item, this.configs)))
});
return data;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-plugin-aurora",
"version": "1.8.3",
"version": "0.0.0-semantic-release",
"description": "A plugin for Hexo Aurora theme",
"main": "index.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md', 'data/**', 'lib/**', 'index.js', 'package.json'],
assets: ['CHANGELOG.md', 'data/**', 'lib/**', 'index.js'],
message:
'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
Expand Down

0 comments on commit 978cd9d

Please sign in to comment.