|
1 | | -# mkdocs-git-revision-date-plugin |
| 1 | +# mkdocs-git-revision-date-localized-plugin |
2 | 2 |
|
3 | | -MkDocs plugin for setting revision date from git per markdown file. |
| 3 | +[MkDocs](https://www.mkdocs.org/) plugin that displays the localized date of the last modification of a markdown file. Forked from [mkdocs-git-revision-date-plugin](https://github.com/zhaoterryy/mkdocs-git-revision-date-plugin) |
4 | 4 |
|
5 | 5 | ## Setup |
| 6 | + |
6 | 7 | Install the plugin using pip: |
7 | 8 |
|
8 | | -`pip install mkdocs-git-revision-date-plugin` |
| 9 | +```bash |
| 10 | +# FIRST VERSION NOT YET PUBLISHED |
| 11 | +pip install mkdocs-git-revision-date-localized-plugin |
| 12 | +``` |
9 | 13 |
|
10 | 14 | Activate the plugin in `mkdocs.yml`: |
| 15 | + |
11 | 16 | ```yaml |
12 | 17 | plugins: |
13 | | - - search |
14 | 18 | - git-revision-date |
15 | 19 | ``` |
16 | 20 |
|
17 | | -> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly. |
| 21 | +## Usage |
18 | 22 |
|
19 | | -More information about plugins in the [MkDocs documentation][mkdocs-plugins]. |
| 23 | +### In theme templates |
20 | 24 |
|
21 | | -## Usage |
22 | | -The revision date will be displayed in ISO format *(YYYY-mm-dd)*. |
| 25 | +In templates you can use `page.meta.git_revision_date_localized`: |
23 | 26 |
|
24 | | -### Templates - `page.meta.revision_date`: |
25 | | -#### Example |
26 | 27 | ```django hljs |
27 | | -{% block footer %} |
28 | | -<hr> |
29 | | -<p>{% if config.copyright %} |
30 | | -<small>{{ config.copyright }}<br></small> |
| 28 | +{% if page.meta.git_revision_date_localized %} |
| 29 | +<small><br><i>Updated {{ page.meta.git_revision_date_localized }}</i></small> |
31 | 30 | {% endif %} |
32 | | -<small>Documentation built with <a href="https://www.mkdocs.org/">MkDocs</a>.</small> |
33 | | -{% if page.meta.revision_date %} |
34 | | -<small><br><i>Updated {{ page.meta.revision_date }}</i></small> |
35 | | -{% endif %} |
36 | | -</p> |
37 | | -{% endblock %} |
38 | 31 | ``` |
39 | | -More information about templates [here][mkdocs-template]. |
40 | 32 |
|
41 | | -More information about blocks [here][mkdocs-block]. |
| 33 | +### In markdown pages |
42 | 34 |
|
43 | | -### Markdown - `{{ git_revision_date }}`: |
44 | | -#### Example |
45 | | -```md |
46 | | -Page last revised on: {{ git_revision_date }} |
47 | | -``` |
48 | | -If using [mkdocs_macro_plugin][mkdocs-macro], it must be included after our plugin. |
| 35 | +In your markdown files you can use `{{ git_revision_date_localized }}`: |
49 | 36 |
|
50 | | -i.e., mkdocs.yml: |
51 | | -```yaml |
52 | | -plugins: |
53 | | - - search |
54 | | - - git-revision-date |
55 | | - - macros |
| 37 | +```django hljs |
| 38 | +Updated {{ git_revision_date_localized_iso }} |
56 | 39 | ``` |
57 | 40 |
|
| 41 | +## Localization updates |
58 | 42 |
|
59 | | -[mkdocs-plugins]: https://www.mkdocs.org/user-guide/plugins/ |
60 | | -[mkdocs-template]: https://www.mkdocs.org/user-guide/custom-themes/#template-variables |
61 | | -[mkdocs-block]: https://www.mkdocs.org/user-guide/styling-your-docs/#overriding-template-blocks |
62 | | -[mkdocs-macro]: https://github.com/fralau/mkdocs_macros_plugin |
| 43 | +There are three date formats: |
63 | 44 |
|
64 | | -## Options |
| 45 | +- A date string format (using [babel](https://github.com/python-babel/babel/tree/master/babel) |
| 46 | +- A ISO format *(YYYY-mm-dd)* |
| 47 | +- A time ago format (using [timeago](https://github.com/hustcc/timeago) |
| 48 | + |
| 49 | +```django hljs |
| 50 | +<i>Updated {{ git_revision_date_localized }}</i> |
| 51 | +<i>Updated {{ git_revision_date_localized_iso }}</i> |
| 52 | +<i>Updated {{ git_revision_date_localized_timeago }}</i> |
| 53 | +``` |
65 | 54 |
|
66 | | -### `enabled_if_env` |
| 55 | +Output: |
67 | 56 |
|
68 | | -Setting this option will enable the build only if there is an environment variable set to 1. Default is not set. |
| 57 | +``` |
| 58 | +Updated 28 November, 2019 |
| 59 | +Updated 2019-11-28 |
| 60 | +Updated 20 hours agon |
| 61 | +``` |
| 62 | + |
| 63 | +## Options |
69 | 64 |
|
70 | | -### `modify_md` |
| 65 | +### `locale` |
71 | 66 |
|
72 | | -Setting this option to false will disable the use of `{{ git_revision_date }}` in markdown files. Default is true. |
| 67 | +Set this option to a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code to use a another language. This will overwrite any locale setting in `mkdocs` or your theme. If no locale is set fallback is English (`en`). |
0 commit comments