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

hexo.locals.get('posts') doesn't show all posts #5287

Open
5 tasks done
D-Sketon opened this issue Sep 3, 2023 · 2 comments
Open
5 tasks done

hexo.locals.get('posts') doesn't show all posts #5287

D-Sketon opened this issue Sep 3, 2023 · 2 comments
Labels
bug Something isn't working need-investigation

Comments

@D-Sketon
Copy link
Member

D-Sketon commented Sep 3, 2023

Check List

Please check followings before submitting a new issue.

Expected behavior

Actual behavior

#5286 #5194 #5230

How to reproduce?

register new tag function

hexo.extend.tag.register("series",() => {
  console.log(hexo.locals.get('posts').length)
},{ends: false});

create three posts like this:

---
title: test1
date: 2023-09-03 16:59:42
tags: tag1
---
{% series %}
---
title: test2
date: 2023-09-03 16:59:46
tags: tag1
---
---
title: test3
date: 2023-09-03 16:59:49
tags: tag1
---

hexo g and the output result is 2

However, if all tags in the post are removed, the result is 3

Is the problem still there under "Safe mode"?

Environment & Settings

Node.js & npm version(node -v && npm -v)

v18.12.1
8.19.2

Your site _config.yml (Optional)

Hexo and Plugin version(npm ls --depth 0)

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "6.3.0"
  },
  "dependencies": {
    "hexo": "^6.3.0",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^3.0.0",
    "hexo-generator-tag": "^2.0.0",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-marked": "^6.0.0",
    "hexo-renderer-stylus": "^3.0.0",
    "hexo-server": "^3.0.0",
    "hexo-theme-landscape": "^1.0.0"
  }
}

Others

@uiolee
Copy link
Member

uiolee commented Sep 4, 2023

i make a test and it works well

hexojs#5194(comment)

I also had this problem and it was weird

@D-Sketon
Copy link
Member Author

I try to remove cache here and it works.

hexo/lib/hexo/locals.ts

Lines 15 to 20 in bc53720

return this.cache.apply(name, () => {
const getter = this.getters[name];
if (!getter) return;
return getter();
});

But I don't think that's where the problem lies.

@D-Sketon D-Sketon added the bug Something isn't working label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need-investigation
Projects
None yet
Development

No branches or pull requests

2 participants