Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into auroral-ui-main
  • Loading branch information
Ryaang committed Feb 5, 2024
2 parents df4bdc6 + a188d3e commit 1dff272
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 36 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# hexo-plugin-aurora
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauroral-ui%2Fhexo-plugin-aurora.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauroral-ui%2Fhexo-plugin-aurora?ref=badge_shield)


This plugin is used for [aurora-ui/hexo-theme-aurora-s](https://github.com/Tim-Saijun/hexo-theme-aurora-s) to do the following:

Expand Down
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 @@ -233,7 +233,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 @@ -265,7 +265,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 @@ -311,7 +311,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-s",
"version": "1.0.11",
"version": "0.0.0-semantic-release",
"description": "Modified 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 1dff272

Please sign in to comment.