Skip to content
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

fix: 规范部分代码语法格式 #1

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.8.4](https://github.com/auroral-ui/hexo-plugin-aurora/compare/v1.8.3...v1.8.4) (2023-11-01)


### Bug Fixes

* category and post generator missing config options ([f3896cc](https://github.com/auroral-ui/hexo-plugin-aurora/commit/f3896ccd0f2c80e115d499f2947f123cd7bad6e6))

## [1.8.3](https://github.com/auroral-ui/hexo-plugin-aurora/compare/v1.8.2...v1.8.3) (2023-09-16)


Expand Down
6 changes: 6 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](https://github.com/auroral-ui/hexo-theme-aurora) to do the following:

Expand All @@ -11,3 +13,7 @@ This plugin is used for [aurora-ui/hexo-theme-aurora](https://github.com/auroral
- Multi-language support

> This plugin can only to be used with **hexo-theme-aurora** only!


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauroral-ui%2Fhexo-plugin-aurora.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauroral-ui%2Fhexo-plugin-aurora?ref=badge_large)
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