-
-
Notifications
You must be signed in to change notification settings - Fork 601
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 modified time #1839
feat: add modified time #1839
Conversation
β Deploy Preview for nuxt-content canceled.Built without sensitive environment variables
|
Can use unjs/unstorage#136 |
Unfortunately, the created time can't be get from unstorage because it create a new file and return time from this new file. |
After deeper investigations, it seems that However, in the file So, there is no way to easily get creation date from a content file. |
I also want to figure out how to get the created and updated time. Checked out the starckoverflow you mention above, the answer provides an idea: each commit has timestamp So my solution is searching the added commit and last updated commit associated with the specify file and get the timestamp I write a server plugin for my Nuxt Content project BlogiNote /**
* add timestamp for markdown file
*/
import { execSync } from 'node:child_process'
// ...
export default defineNitroPlugin((nitroApp) => {
// ...
const firstCommitTime = execSync(`git log --diff-filter=A --format=%as -- ${filePath}`, { encoding: 'utf-8' }).trim();
// ...
const lastCommitTime = execSync(`git log -1 --format=%as -- ${filePath}`, { encoding: 'utf-8' }).trim();
// ...
}) This won't be the precise time as the created and updated, and it works! However I encouter another problem, this method just work fine locally. When I deploy to Vercel, because the |
π Linked issue
β Type of change
π Description
π Checklist