Feature Request: Add config option to use data.page.date #4
DougReeder
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
It is not obvious, but you can use import eleventyPluginContentDates from '@web-alchemy/eleventy-plugin-content-dates';
const {
TIMESTAMPS,
computeDate,
getContentFolderPath,
getContentFilePath
} = eleventyPluginContentDates;
module.exports = {
eleventyComputed: {
updatedAt(data) {
return computeDate({
strategy: data.eleventy.env.runMode !== 'build' ? TIMESTAMPS.FS_LAST_MODIFIED : TIMESTAMPS.GIT_LAST_MODIFIED,
// get date for main template file
contentPath: getContentFilePath
// or get date for all folder containing template file
contentPath: getContentFolderPath
})
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checking git is expensive when there are many files, and the exact dates rarely matter except for the final build that users see. It speeds performance to use
data.page.date
instead.I propose a boolean configuration option that when enabled would return
data.page.date
, if a date field isDate. Git. Created
orDate. Git. Last Modified
This being a configuration option, the user could use, for example
data.eleventy.env.runMode !== 'build'
orprocess.env.NODE_ENV === 'production'
or whatever criterion met their use case.Beta Was this translation helpful? Give feedback.
All reactions