You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ plugins:
37
37
38
38
> 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.
39
39
40
-
If you use the [mkdocs-material](https://squidfunk.github.io/mkdocs-material/) theme, you should already see the last revision on the bottom of your pages.
40
+
The [mkdocs-material](https://squidfunk.github.io/mkdocs-material/) theme has built in support for `git-revision-date-localized` and you should already see the last revision date on the bottom of your pages. See the [documentation](https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html) on how to fine-tune the appearance and the date format.
|`git-revision-date-localized`| Last git commit that touched a file. Enabled by default. |
8
+
|`git-creation-date-localized`| First git commit that touched a file. Enable in [options](options.md). |
9
+
|`git_site_revision_date_localized`| Last git commit that touched any file in the `docs/` folder. Enabled by default. |
10
+
11
+
You can use these variables wrapped in curly brackets (`{{` and `}}`) anywhere in a markdown file, like so:
12
+
13
+
<preid="__code_42"><span></span><buttonclass="md-clipboard md-icon"title="Copy to clipboard"data-clipboard-target="#__code_42 > code"></button><code>This page was last updated: *{{ git_revision_date_localized }}*
14
+
</code></pre>
15
+
16
+
Example output: This page was last updated *{{ git_revision_date_localized }}*.
17
+
18
+
Changing the `type`, `timezone` and/or `locale` in the [options](options.md) will effect the output of these variables. To change the styling see [Applying custom styling](howto/custom-styling.md).
19
+
20
+
## Variables for overriding themes
21
+
22
+
If you do not want to include revision dates manually in each markdown file, or if you would like more control on the formatting, you can [override a theme](howto/override-a-theme.md). You can use the same three variables but with a `page.meta.` prefix:
23
+
24
+
-`page.meta.git-revision-date-localized`
25
+
-`page.meta.git-creation-date-localized`
26
+
-`page.meta.git_revision_date_localized_raw_date`
27
+
28
+
To allow for more flexibility when overriding a theme there are also variables for each different `type` available (regardless of the setting for `type` in [options](options.md)), where the output is also not wrapped in `<span>` elements (so you can do the CSS styling yourself):
You might want to change the appearance of the dates in your theme. You can style the output using CSS, for example by [including extra css](https://www.mkdocs.org/user-guide/configuration/#extra_css) to your mkdocs site.
3
+
You can change the appearance of the revision dates by [including extra CSS](https://www.mkdocs.org/user-guide/configuration/#extra_css) to your mkdocs site.
4
4
5
-
The date outputs are always wrapped in `span` elements with the classes `git-revision-date-localized-plugin` and `git-revision-date-localized-plugin-{type}` (where `{type}` is replaced with the `type` option set in the plugin).
5
+
## CSS Classes
6
6
7
-
Here's an example:
7
+
To allow for easier styling date outputs are wrapped in `<span>` elements with the classes `git-revision-date-localized-plugin` and `git-revision-date-localized-plugin-{type}`, where `{type}` is replaced with the `type` set in the plugin settings (see [options](../options.md)).
8
8
9
-
=== "mkdocs.yml"
9
+
For example when `type: datetime` is set, using the following in a markdown file:
10
10
11
-
```yaml
12
-
extra_css:
13
-
css/extra.css
14
-
```
11
+
<preid="__code_42"><span></span><buttonclass="md-clipboard md-icon"title="Copy to clipboard"data-clipboard-target="#__code_42 > code"></button><code>Last update: {{ git_revision_date_localized }}
You can [customize an existing theme](https://www.mkdocs.org/user-guide/styling-your-docs/#customizing-a-theme) by overriding blocks or partials. You might want to do this because your theme is not natively supported, or you would like more control on the formatting. Below are some examples to get you started.
3
+
You can [customize an existing theme](https://www.mkdocs.org/user-guide/styling-your-docs/#customizing-a-theme) by overriding blocks or partials. You might want to do this because your theme is not natively supported, or you would like more control on the formatting. Below are two examples to help get you started.
4
4
5
5
## Example: default `mkdocs` theme
6
6
7
7
To add a revision date to the default `mkdocs` theme, add a `overrides/partials` folder to your `docs` folder and update your `mkdocs.yml` file.
8
8
Then you can extend the base `mkdocs` theme by adding a new file `docs/overrides/content.html`:
@@ -41,17 +42,19 @@ Then you can extend the base `mkdocs` theme by adding a new file `docs/overrides
41
42
42
43
## Example: `mkdocs-material` theme
43
44
44
-
[mkdocs-material](https://squidfunk.github.io/mkdocs-material/) has native support for `git_revision_date_localized` and `git_created_date_localized`. If you want, you can customize further by [extending the mkdocs-material theme](https://squidfunk.github.io/mkdocs-material/customization/#extending-the-theme) and overriding the [`source-file.html`](https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-file.html) partial as follows:
45
+
[mkdocs-material](https://squidfunk.github.io/mkdocs-material/) has built-in support for `git_revision_date_localized` and `git_created_date_localized`. You can see that when viewing their [`source-file.html`](https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/source-file.html) partial.
45
46
46
-
=== "mkdocs.yml"
47
+
If you want, you can customize further by [extending the mkdocs-material theme](https://squidfunk.github.io/mkdocs-material/customization/#extending-the-theme) and overriding the `source-file.html` partial as follows:
When customizing or [writing your own themes](https://www.mkdocs.org/user-guide/custom-themes/)`mkdocs-revision-date-localized-plugin` will make available the following jinja variables:
84
-
85
-
-`page.meta.git_revision_date_localized`
86
-
-`page.meta.git_creation_date_localized`
87
-
88
-
To insert these variables in a partial/block/template, use the jinja2 bracks `{{` and `}}`. The values of these variables depend on the plugin options specified, and are wrapped in `<span>` elements. For example, when using `type: timeago` (see [options](../options.md)):
89
-
90
-
=== "input"
91
-
92
-
```django
93
-
{% if page.meta.git_revision_date_localized %}
94
-
Last update: {{ page.meta.git_revision_date_localized }}
95
-
{% endif %}
96
-
```
97
-
98
-
=== "output"
99
-
100
-
```django
101
-
Last update: <span class="timeago" datetime="2021-11-03T12:25:03+01:00" locale="en" timeago-id="5"></span>
102
-
```
103
-
104
-
!!! info "Note"
105
-
106
-
When `type: timeago` option is used, `mkdocs-revision-date-localized-plugin` adds [timeago.js](https://timeago.org/) to your mkdocs website, which dynamically inserts a value between the `<span>` elements like `2 weeks ago`.
107
-
108
-
109
-
As a developer you might want access to multiple 'raw' date types. These variables also do not have the `<span>` elements. You can use:
Copy file name to clipboardExpand all lines: docs/options.md
+35-31Lines changed: 35 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,26 @@
2
2
3
3
You can customize the plugin by setting options in `mkdocs.yml`. For example:
4
4
5
-
```yaml
6
-
plugins:
7
-
- git-revision-date-localized:
8
-
type: timeago
9
-
timezone: Europe/Amsterdam
10
-
locale: en
11
-
fallback_to_build_date: false
12
-
enable_creation_date: true
13
-
exclude:
14
-
- index.md
15
-
enabled: true
16
-
```
5
+
=== ":octicons-file-code-16: mkdocs.yml"
6
+
7
+
```yaml
8
+
plugins:
9
+
- git-revision-date-localized:
10
+
type: timeago
11
+
timezone: Europe/Amsterdam
12
+
locale: en
13
+
fallback_to_build_date: false
14
+
enable_creation_date: true
15
+
exclude:
16
+
- index.md
17
+
enabled: true
18
+
```
17
19
18
20
## `type`
19
21
20
22
Default is `date`. The format of the date to be displayed. Valid values are `date`, `datetime`, `iso_date`, `iso_datetime` and `timeago`. Example outputs:
21
23
22
-
```
24
+
```yaml
23
25
28 November, 2019 # type: date (default)
24
26
28 November, 2019 13:57:28 # type: datetime
25
27
2019-11-28 # type: iso_date
@@ -41,7 +43,7 @@ Default is `None`. Specify a two letter [ISO639](https://en.wikipedia.org/wiki/L
41
43
42
44
Example outputs:
43
45
44
-
```
46
+
```yaml
45
47
27 April, 2021 # `locale: en` with `type: date` (default)
46
48
27 April, 2021 13:11:28 # `locale: en` with `type: datetime`
47
49
2 weeks ago # `locale: en` with `type: timeago`
@@ -56,33 +58,35 @@ Default is `false`. Enables falling back to the time when `mkdocs build` was exe
56
58
57
59
## `enable_creation_date`
58
60
59
-
Default is `false`. Enables adding a *Created* date at the bottom of each page on [supported themes](getting-started.md#supported-themes). Also enables use of <code>\{\{ git_creation_date_localized }}</code> in markdown files and `page.meta.git_creation_date_localized` in page templates.
61
+
Default is `false` (because it has a small effect on build time). Enables adding a *Created* date at the bottom of each page on [supported themes](getting-started.md#supported-themes). Also enables use of <code>\{\{ git_creation_date_localized }}</code> in markdown files and `page.meta.git_creation_date_localized` in page templates.
60
62
61
63
## `exclude`
62
64
63
65
Default is empty. Specify a list of page source paths (one per line) that should not have a revision date included (excluded from processing by this plugin). This can be useful for example to remove the revision date from the front page. The source path of a page is relative to your `docs/` folder. You can also use [globs](https://docs.python.org/3/library/glob.html) instead of full source paths. To exclude `docs/subfolder/page.md` specify in your `mkdocs.yml` a line under `exclude:` with `- subfolder/page.md`. Some examples:
64
66
65
-
```yaml
66
-
# mkdocs.yml
67
-
plugins:
68
-
- git-revision-date-localized:
69
-
exclude:
70
-
- index.md
71
-
- subfolder/page.md
72
-
- another_page.md
73
-
- folder/*
74
-
```
67
+
=== ":octicons-file-code-16: mkdocs.yml"
68
+
69
+
```yaml
70
+
plugins:
71
+
- git-revision-date-localized:
72
+
exclude:
73
+
- index.md
74
+
- subfolder/page.md
75
+
- another_page.md
76
+
- folder/*
77
+
```
75
78
76
79
## `enabled`
77
80
78
81
Default is `true`. Enables you to deactivate this plugin. A possible use case is local development where you might want faster build times and/or do not have git available. It's recommended to use this option with an environment variable together with a default fallback (introduced in `mkdocs` v1.2.1, see [docs](https://www.mkdocs.org/user-guide/configuration/#environment-variables)). Example:
79
82
80
-
```yaml
81
-
# mkdocs.yml
82
-
plugins:
83
-
- git-revision-date-localized:
84
-
enabled: !ENV [ENABLED_GIT_REVISION_DATE, True]
85
-
```
83
+
=== ":octicons-file-code-16: mkdocs.yml"
84
+
85
+
```yaml
86
+
plugins:
87
+
- git-revision-date-localized:
88
+
enabled: !ENV [ENABLED_GIT_REVISION_DATE, True]
89
+
```
86
90
87
91
Which enables you do disable the plugin locally using:
0 commit comments