{"action":"created","issue":{"url":"https://api.github.com/repos/hexojs/hexo/issues/3027","repository_url":"https://api.github.com/repos/hexojs/hexo","labels_url":"https://api.github.com/repos/hexojs/hexo/issues/3027/labels{/name}","comments_url":"https://api.github.com/repos/hexojs/hexo/issues/3027/comments","events_url":"https://api.github.com/repos/hexojs/hexo/issues/3027/events","html_url":"https://github.com/hexojs/hexo/issues/3027","id":297980837,"number":3027,"title":"Use `post.categories` in `<% if() %>`","user":{"login":"liurui39660","id":20491264,"avatar_url":"https://avatars0.githubusercontent.com/u/20491264?v=4","gravatar_id":"","url":"https://api.github.com/users/liurui39660","html_url":"https://github.com/liurui39660","followers_url":"https://api.github.com/users/liurui39660/followers","following_url":"https://api.github.com/users/liurui39660/following{/other_user}","gists_url":"https://api.github.com/users/liurui39660/gists{/gist_id}","starred_url":"https://api.github.com/users/liurui39660/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liurui39660/subscriptions","organizations_url":"https://api.github.com/users/liurui39660/orgs","repos_url":"https://api.github.com/users/liurui39660/repos","events_url":"https://api.github.com/users/liurui39660/events{/privacy}","received_events_url":"https://api.github.com/users/liurui39660/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-17T05:24:28Z","updated_at":"2018-02-17T06:45:19Z","closed_at":"2018-02-17T06:45:19Z","author_association":"NONE","body":"<!--\r\nThank you for reporting an issue. For general issues/bugs, please view https://hexo.io/docs/troubleshooting.html .\r\nBefore you submit your issue, please provide the following information as much as possible.\r\n-->\r\n\r\n## Environment Info\r\n\r\nNode version(`node -v`):\r\nv9.4.0\r\nHexo and Plugin version(`npm ls --depth 0`): \r\nhexo-site@0.0.0 E:\\Blog\r\n+-- hexo@3.5.0\r\n+-- hexo-deployer-git@0.3.1\r\n+-- hexo-generator-archive@0.1.5\r\n+-- hexo-generator-baidu-sitemap@0.1.2\r\n+-- hexo-generator-category@0.1.3\r\n+-- hexo-generator-index@0.2.1\r\n+-- hexo-generator-search@2.1.1\r\n+-- hexo-generator-sitemap@1.2.0\r\n+-- hexo-generator-tag@0.2.0\r\n+-- hexo-helper-qrcode@1.0.2\r\n+-- hexo-inject@1.0.0\r\n+-- hexo-math@3.0.4\r\n+-- hexo-renderer-ejs@0.3.1\r\n+-- hexo-renderer-mathjax@0.6.0\r\n+-- hexo-renderer-pandoc@0.2.2\r\n+-- hexo-renderer-stylus@0.3.3\r\n`-- hexo-server@0.2.2\r\n\r\n## For question\r\n\r\nI'd like to implement a feature in my theme, it is simple:\r\n\r\n```html\r\n<% if (post.categories==\"Some Categories\") { %>\r\n    do some things\r\n<% } else { %>\r\n    do other things\r\n<% } %>\r\n```\r\n\r\nBut the code in the `else` part won't be executed, even if the `post.categories` is (or contains, I know the `post.categories` is an array) \"Some Categories\".\r\n\r\nI tried to print the `post.categories` with the code:\r\n\r\n```html\r\n<p><%= post.categories %></p>\r\n```\r\n\r\nBut it only shows `[object Object]`.\r\n\r\nWhat shall I do to?"},"comment":{"url":"https://api.github.com/repos/hexojs/hexo/issues/comments/366421849","html_url":"https://github.com/hexojs/hexo/issues/3027#issuecomment-366421849","issue_url":"https://api.github.com/repos/hexojs/hexo/issues/3027","id":366421849,"user":{"login":"liurui39660","id":20491264,"avatar_url":"https://avatars0.githubusercontent.com/u/20491264?v=4","gravatar_id":"","url":"https://api.github.com/users/liurui39660","html_url":"https://github.com/liurui39660","followers_url":"https://api.github.com/users/liurui39660/followers","following_url":"https://api.github.com/users/liurui39660/following{/other_user}","gists_url":"https://api.github.com/users/liurui39660/gists{/gist_id}","starred_url":"https://api.github.com/users/liurui39660/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liurui39660/subscriptions","organizations_url":"https://api.github.com/users/liurui39660/orgs","repos_url":"https://api.github.com/users/liurui39660/repos","events_url":"https://api.github.com/users/liurui39660/events{/privacy}","received_events_url":"https://api.github.com/users/liurui39660/received_events","type":"User","site_admin":false},"created_at":"2018-02-17T06:45:19Z","updated_at":"2018-02-17T06:45:19Z","author_association":"NONE","body":"I solved this problem myself, I modify the code into:\r\n\r\n```html\r\n<% if (post.categories.data[0].name==\"Some Categories\") { %>\r\n    do some things\r\n<% } else { %>\r\n    do other things\r\n<% } %>\r\n```"}}
{"actor":{"display_login":"liurui39660"}}