hexo icon indicating copy to clipboard operation
hexo copied to clipboard

site.categories.data is not iterable

Open D-Sketon opened this issue 7 months ago • 8 comments

Check List

  • [X] I have already read Docs page & Troubleshooting page.
  • [X] I have already searched existing issues and they are not help to me.
  • [X] I examined error or warning messages and it's difficult to solve.
  • [X] I am using the latest version of Hexo. (run hexo version to check)
  • [X] My Node.js is matched the required version.

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:

_Query {
  data: [
    _Document {
      name: 'test1',
      _id: 'clph3uowl0001y0vr98rqaoln',
      slug: [Getter],
      path: [Getter],
      permalink: [Getter],
      posts: [Getter],
      length: [Getter]
    }
  ],
  length: 1
}

after PR:

_Model {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  name: 'Category',
  _mutex: Mutex { _locked: false, _queue: [] },
  data: {
    clph3uy05000130vr2iwbbjgi: { name: 'test1', _id: 'clph3uy05000130vr2iwbbjgi' }
  },
  length: 1,
  schema: Schema {
    paths: {
      name: [SchemaTypeString],
      parent: [SchemaTypeCUID],
      slug: [SchemaTypeVirtual],
      path: [SchemaTypeVirtual],
      permalink: [SchemaTypeVirtual],
      posts: [SchemaTypeVirtual],
      length: [SchemaTypeVirtual],
      _id: [SchemaTypeCUID]
    },
    statics: {},
    methods: {},
    hooks: { pre: [Object], post: [Object] },
    stacks: {
      getter: [Array],
      setter: [Array],
      import: [Array],
      export: [Array]
    }
  },
  Document: [class _Document extends Document],
  Query: [class _Query extends Query],
  [Symbol(kCapture)]: false
}

How to reproduce?

just use v7 related PR: https://github.com/hexojs/hexo/pull/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

https://github.com/hexojs/hexo/blob/f5e0f92eda9491116c585142c565efcf7bf7a3e3/lib/hexo/index.ts#L297-L299

D-Sketon avatar Nov 28 '23 02:11 D-Sketon