Skip to content

Commit 900eb76

Browse files
Added param for git_path
Co-authored-by: William Seiti Mizuta <[email protected]>
1 parent ec6715f commit 900eb76

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ Specify a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_co
9191

9292
If set to `true` (default is `false`) the plugin will use the time when running `mkdocs build` instead of the git revision date. This means the revision date will be inaccurate, but this can be useful if your build environment has no access to GIT and you want to ignore the Git exceptions during `git log`.
9393

94+
### `git_path`
95+
96+
Specify a path to the folder that is a git repository (the folder that contains `.git`).
97+
If not specified, default path is `.`.
98+
9499
----
95100

96101
### Example
@@ -104,6 +109,7 @@ plugins:
104109
locale: en
105110
type: timeago
106111
fallback_to_build_date: true
112+
git_path: ./docs
107113
```
108114

109115
Result:

mkdocs_git_revision_date_localized_plugin/plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ class GitRevisionDateLocalizedPlugin(BasePlugin):
1616
("fallback_to_build_date", config_options.Type(bool, default=False)),
1717
("locale", config_options.Type(str, default=None)),
1818
("type", config_options.Type(str, default="date")),
19+
("git_path", config_options.Type(str, default=".")),
1920
)
2021

2122
def __init__(self):
22-
self.util = Util()
23+
pass
2324

2425
def on_config(self, config: config_options.Config) -> dict:
2526
"""
@@ -37,6 +38,8 @@ def on_config(self, config: config_options.Config) -> dict:
3738
dict: global configuration object
3839
"""
3940

41+
self.util = Util(path=self.config.get("git_path", "."))
42+
4043
# Get locale settings - might be added in future mkdocs versions
4144
# see: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/issues/24
4245
mkdocs_locale = config.get("locale", None)

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class Util:
13-
def __init__(self, path: str = "./docs"):
13+
def __init__(self, path: str):
1414
self.repo = Git(path)
1515

1616
# Checks when running builds on CI

0 commit comments

Comments
 (0)