-
-
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
feat: add permalink variable timestamp
#5611
base: master
Are you sure you want to change the base?
Conversation
How to testgit clone -b timestamp https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test |
f819977
to
a13326d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Pull Request Test Coverage Report for Build 12764580920Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add :update_timestamp
as well IMHO?
I'm not sure if there is such a use case. But generally speaking, |
second: date.format('ss'), | ||
i_month: date.format('M'), | ||
i_day: date.format('D'), | ||
timestamp: date.format('X'), | ||
hash, | ||
category: config.default_category |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, we could use an approach like the following to only calculate the permalink value when needed, and cache it afterward:
function defineLazyProperty(object, propertyName, valueGetter) {
const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
Object.defineProperty(object, propertyName, {
configurable: true, enumerable: true,
get() {
const result = valueGetter();
define(result);
return result;
},
set: define
});
return object;
}
const permalink = {};
defineLazyProperty(permalink, 'second', () => date.format('ss'));
// ...
defineLazyProperty(permalink, 'timestamp', () => date.format('X'));
Or we can use Map
instead of object
here.
We can do this in another PR.
What does it do?
fix #5586
Screenshots
Pull request tasks
:timestamp
site#2326