facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.32k stars 8.45k forks source link

Last updated: feeding data through front matter, new "created" metadata #5691

Open Josh-Cena opened 3 years ago

Josh-Cena commented 3 years ago

🚀 Feature

Two things:

Have you read the Contributing Guidelines on issues?

Yes

Has this been requested on Canny?

Requested multiple times on Discord

Motivation

The "created" metadata can be used to differentiate between "new" pages and "deprecated" pages. "Last updated" shouldn't be entirely relying on git history since that can be buggy sometimes.

API Design

Front matter options:

last_update_time: Date | string
last_update_author: string
create_time: Date | string
create_author: string

New config options showCreateTime and showCreateAuthor

The implementation of "create time" shouldn't be too hard with git, but it can also be messed up in versioning, so🤷‍♂️ Front matter metadata FTW

Have you tried building it?

No

slorber commented 3 years ago

Agree that using frontmatter options to override defaults is a good idea.

With a createFrontMatter() option that I'd like to add, this would also allow users to provide their own code logic, eventually reading it from SVN/Mercurial/CMS/other systems.

Josh-Cena commented 3 years ago

I will probably build this feature myself after the createFrontMatter() landed, since then we can get rid of the hard-coded last updated generation method and just inject that as a default

Josh-Cena commented 2 years ago

@slorber proposed in #7263 a similar API:

last_update:
  author: string
  date: string

I think that makes sense as well. We can possibly add other data in this namespace. Maybe we can even extend it to a history API if people want the last few revisions? (See #6218)

history:
  # First item: creation
  - author: ...
    date: ...
  - author: ...
    date: ...
  # Last item: last update
  - author: ...
    date: ...
Josh-Cena commented 2 years ago

Now that createFrontMatter() is probably not coming through in the near future, we can implement this first, just without an automated way to fill it.

dpang314 commented 2 years ago

I would like to work on this. Should I implement the history or only the last update?

Josh-Cena commented 2 years ago

@dpang314 Let's start with a back-compatible lastUpdate first.

dpang314 commented 2 years ago

Will do.

slorber commented 2 years ago

A new "created" metadata (using git history)

The "created" metadata can be used to differentiate between "new" pages and "deprecated" pages.

As we discussed on discord, I'm not sure to understand the use-case for this 🤪

In any case, making it possible for users to access a "created" metadata might have some benefits, just not sure to understand yet how it would be used in practice.

alikazemi1259 commented 2 years ago

Dear friends, I am very happy with your kindness. I hope that together we will achieve the desired results and have a very good recovery. Friends, if you have any problems, please send me a message. I will be very happy to be able to serve my loved ones. May our family and others take good advantage of this website and benefit from it. In the hope of health, happiness and happiness. Blessings, victory, pride and honor for all your loved ones and families. May your night and day be full of God's blessings and love. May you all be under the shadow of God's love and kindness.

randallb commented 2 years ago

Hi-- I'm interested in working on this. It seems like it would be pretty simple... yeah? I'll give it a shot over the next lil' bit and let you know how far I get.