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

"post.date" passed in as current date when its not set / null #4621

Closed
jashsayani opened this issue Jan 24, 2021 · 5 comments
Closed

"post.date" passed in as current date when its not set / null #4621

jashsayani opened this issue Jan 24, 2021 · 5 comments
Labels

Comments

@jashsayani
Copy link

When I use "page", I do not want to have a date (I only use date for "post"). If I un-set the date (dont have it set in md), its still passed in as current date to my theme.

Expected behavior

post.date is falsey.

Actual behavior

post.date is current date.

How to reproduce?

Use this page (no date set):

---
title: My Page
---
## My title
Hello World

Environment & Settings

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

v12.18.3
6.14.6

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

jashs-blog@1.0.0 /Users/Jash/Workbox/jashs-blog
├── hexo@5.3.0
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-tag@1.0.0
├── hexo-migrator-wordpress@2.1.2
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@3.2.0
├── hexo-renderer-stylus@2.0.1
└── hexo-server@2.0.0

Your package.json package.json

{
  "name": "jashs-blog",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "5.3.0"
  },
  "dependencies": {
    "hexo": "^5.3.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-migrator-wordpress": "^2.1.2",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^3.2.0",
    "hexo-renderer-stylus": "^2.0.0",
    "hexo-server": "^2.0.0"
  }
}

Others

I added this to my page in the theme file <h1><%= post.date %></h1> and I see Sat Jan 23 2021 22:24:47 GMT-0800 when no date is set.

@github-actions
Copy link

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Apr 12, 2021
@jashsayani
Copy link
Author

This is still an issue.

@github-actions github-actions bot removed the stale label Apr 13, 2021
@jiangtj
Copy link
Member

jiangtj commented Apr 13, 2021

https://hexo.io/docs/helpers#is-page

You can use is_page() helper to determine whether to display the time

@jashsayani
Copy link
Author

You can use is_page() helper to determine whether to display the time

I have a working work-around so this issue is not blocking me. But post.date is not behaving as expected so it should be fixed at some point.

@github-actions
Copy link

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@jashsayani @jiangtj and others