content icon indicating copy to clipboard operation
content copied to clipboard

Missing `createdAt` and `updatedAt` field

Open mrleblanc101 opened this issue 2 years ago • 10 comments

Environment



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. Capture d’écran, le 2023-01-05 à 22 53 50

Additional context

No response

Logs

No response

mrleblanc101 avatar Jan 06 '23 03:01 mrleblanc101

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 ?

mrleblanc101 avatar Jan 06 '23 04:01 mrleblanc101

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.

ManasMadrecha avatar Jan 08 '23 14:01 ManasMadrecha

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.

Barbapapazes avatar Feb 25 '23 09:02 Barbapapazes

And you can manually add a createdAt using frontMatter

Barbapapazes avatar Feb 25 '23 09:02 Barbapapazes

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? :)

goodpixels avatar Aug 01 '23 12:08 goodpixels

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? :)

Where in the documentation?

Barbapapazes avatar Aug 01 '23 13:08 Barbapapazes

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

geoffyuen avatar Sep 06 '23 18:09 geoffyuen

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 avatar May 11 '24 01:05 EtzBetz

@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 avatar May 15 '24 05:05 ManasMadrecha

@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.

EtzBetz avatar May 15 '24 07:05 EtzBetz

@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?

khawarizmus avatar Jan 20 '25 01:01 khawarizmus

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.

farnabaz avatar Jan 21 '25 14:01 farnabaz

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.

github-actions[bot] avatar Mar 22 '25 15:03 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Apr 21 '25 15:04 github-actions[bot]