content
content copied to clipboard
Missing `createdAt` and `updatedAt` field
Environment
- Operating System:
Darwin - Node Version:
v16.14.0 - Nuxt Version:
3.0.0 - Nitro Version:
1.0.0 - Package Manager:
[email protected] - Builder:
vite - User Config:
srcDir,modules,colorMode,postcss,vite - Runtime Modules:
@nuxtjs/[email protected],@nuxtjs/[email protected],@nuxt/[email protected] - Build Modules:
-
Reproduction
Coming
Describe the bug
I want to display the createAt from my blog post and sort my posts by date creation date, but I don't see the createdAt or updatedAt fields in my data unlike what the documentation website says here.

Additional context
No response
Logs
No response
My bad, the search on the v2 website also index the content of the v1 website. So clicking the link redirected me to the v1 website... Odd choice.
The createdAt and updatedAt variables does not exist on v2.
Why tho ?
Those fields anyway were misleading as they were based on file creation date, which changes any time we download/clone the repo. So, better to use manually added fields. Or you can use some VS Code extension or Obsidian plugin to automatically add/update those fields whenever you actually make changes to the file.
In fact, createdAt can't be trusted. (https://stackoverflow.com/questions/62039244/does-git-store-the-file-creation-time).
However, we can add the updatedAt easily thanks to unstorage.
And you can manually add a createdAt using frontMatter
Hang on, but what is the status of this?
The documentation mentions createdAt and updatedAt fields will be auto-generated. If this is not the case, the the docs should be updated accordingly.
So which one is it - do those fields get generated or not? :)
Hang on, but what is the status of this?
The documentation mentions
createdAtandupdatedAtfields will be auto-generated. If this is not the case, the the docs should be updated accordingly.So which one is it - do those fields get generated or not? :)
Where in the documentation?
Where in the documentation?
They probably got there by googling and ended up at the v1 docs which happened to me: https://content.nuxtjs.org/v1/getting-started/writing
In Nuxt v3, I am currently not able to provide any frontmatter attributes which are then also included. Is this by design? I would like to be able to search for tags as well and be able to display creationDate (manually added in frontmatter) in the results.
@EtzBetz Hi, any frontmatter attribute you type in the md file is automatically generated as a key in the content code. You can simply display it inside the current file itself or the Vue page where you are fetching the file.
@ManasMadrecha Oh, I didn't really specify, but I thought it was obvious from the thread. I am talking about search. In search, by default, only title and the content itself are searched.
@farnabaz @larbish Now that V3 uses a database can we expose these two properties or is it still recommended to manually add them in the frontmatter?
Now that V3 uses a database can we expose these two properties or is it still recommended to manually add them in the frontmatter?
The short answer is that the recommended approach is manual dates.
The issue with createdAt and updatedAt is that Git does not keep track of file metadata and when you clone project, metadata will not be the same as the old clone.
Content v3 has a similar approach, it does not keep track of file changes and metadata. The module does not push the local database to the repo and unlike git, it even does not know anything about the content's history. So as a result, each clone of the repository will have different file metadata, and having this variant information makes no sense.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
This issue was closed because it has been stalled for 30 days with no activity.