Skip to content
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

[Feature request] Add Created and Updated datetime on all page #1408

Closed
letientai299 opened this issue Feb 18, 2018 · 11 comments
Closed

[Feature request] Add Created and Updated datetime on all page #1408

letientai299 opened this issue Feb 18, 2018 · 11 comments

Comments

@letientai299
Copy link

It's would be nice to see how recent the document is, like:

image

The Created and Update datetime information can be get from git repository, based on the first and last commit affect to the file.

Reference:

@waylan
Copy link
Member

waylan commented Feb 18, 2018

Using the git commit date/time is reliant upon using git. Of course, not all MkDocs users use git for their documentation. A specific feature like that would be a good candidate for a third party Plugin.

A more general approach would be to use the "build date" which we already make available via the build_date_utc template variable. The existing themes simply don't display it. For example, the mkdocs theme inserts the date into an HTML comment on the homepage only. With a little theme customization, one could include that date elsewhere on pages (see also How do I format a date in Jinja2?).

In short, if you want the "build date" we don't need to do anything. If you want something more specific, you are welcome to create a plugin to address your specific needs. Again there is no need for MkDocs to do anything.

@waylan
Copy link
Member

waylan commented Feb 18, 2018

I should also note that using local file system created and/or modified dates are not reliable either. Someone could create a new clone of a repo today and have "created" dates of today for the local files. Of course that wouldn't necessarily line up with the commit dates. The point is that the only way to get reliable dates/times is to use the version control system's dates/times. However, MkDocs does not enforce any specific version control system(s). So a general solution would be difficult, if not impossible, to build and maintain without limiting the usefulness to specific users only. Therefore, that sort of thing is best served by a third party plugin. One person builds a git specific plugin and someone else can build a mercurial specific plugin and so on.

@biochimia
Copy link

Perhaps it would be interesting to have mkdocs define a baseline for what version control metadata could look like an how it integrates in the base template. Then third-party plugins could fill in this data knowing it would integrate well with the system.

@waylan
Copy link
Member

waylan commented Apr 23, 2018

@biochimia actually I think plugin creators should experiment and find what works best. If, at some point in the future, a single approach becomes wildly popular, then we can explore bringing that plugin in-house at that time.

@GaryPWhite
Copy link

Hey everyone! Looking to use a feature like this, is there any consensus on if this is coming down the pipe?

@Ir1d
Copy link

Ir1d commented Nov 27, 2018

@GaryPWhite It seems that mkdocs is not adding this feature, you can call github api by your self actually. My code: https://github.com/24OI/OI-wiki/blob/master/static/extra.js#L33

@zhaoterryy
Copy link
Contributor

@GaryPWhite You can use my simple plugin here: mkdocs-git-revision-date-plugin

This will fill in page.meta.revision_date allowing you to use it in your templates. It pulls this info from the last time the file was modified and committed to Git.

@Ir1d
Copy link

Ir1d commented Dec 3, 2018

@zhaoterryy Hi, how to use your plugin? should I clone the repo to somewhere or install via pip? Thx

@zhaoterryy
Copy link
Contributor

Right.. sorry about that.

pip install mkdocs-git-revision-date-plugin

@zhaoterryy
Copy link
Contributor

You'll also need to add git-revision-date to your list of plugins in mkdocs.yml

@waylan
Copy link
Member

waylan commented Dec 3, 2018

@zhaoterryy you might want to add your plugin to the list on the wiki so others can find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants