-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
site.categories.data is not iterable #5367
Comments
IMHO, If we can't fix it, we should revert #5119 and release a patch version |
IMHO, Workaroundconst Hexo = require('hexo');
const hexo = new Hexo(process.cwd(), {silent: false});
hexo.init().then(() => {
hexo.load().then(() => {
const categories = hexo.locals.get('categories')
for(const category of Object.values(categories.data)) {
console.log(category)
}
})
}
|
Besides the problem mentioned I have another question that may be relevant. Before v7 the number of articles under each category can be retrieved using |
No, it's not an intentional change, this is a side effect of optimization |
Even through |
This issue is quite tricky. Hexo provides a well-encapsulated |
you can use toArray() const array = hexo.locals.get("tags").toArray();
for (item of array) {
console.log(item.name, item.length);
} forEach() hexo.locals.get("tags").forEach((item) => {
console.log(item.name, item.length);
}); https://hexojs.github.io/warehouse/classes/model.default.html#toArray |
Check List
hexo version
to check)Expected behavior
site.categories.data
site.tags.data
are iterable before v7
Actual behavior
https://github.com/orgs/hexojs/discussions/5355
hexo.locals.get('categories')
before PR:after PR:
How to reproduce?
just use v7
related PR: #5119
This may affect some of the Hexo themes
Is the problem still there under
Safe mode
?/
Your Node.js & npm version
No response
Your Hexo and Plugin version
No response
Your
package.json
No response
Your site's
_config.yml
(Optional)No response
Others
related code
hexo/lib/hexo/index.ts
Lines 297 to 299 in f5e0f92
The text was updated successfully, but these errors were encountered: