nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.05k stars 620 forks source link

Missing `createdAt` and `updatedAt` field #1797

Open mrleblanc101 opened 1 year ago

mrleblanc101 commented 1 year ago

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 commented 1 year ago

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 ?

ManasMadrecha commented 1 year ago

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.

Barbapapazes commented 1 year ago

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 commented 1 year ago

And you can manually add a createdAt using frontMatter

goodpixels commented 1 year ago

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

Barbapapazes commented 1 year ago

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?

geoffyuen commented 11 months ago

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

EtzBetz commented 3 months ago

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.

ManasMadrecha commented 3 months ago

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

EtzBetz commented 3 months ago

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