Skip to content

Add configuration for git path #31

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Specify a two letter [ISO639](https://en.wikipedia.org/wiki/List_of_ISO_639-1_co

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`.

### `git_path`

Specify a path to the folder that is a git repository (the folder that contains `.git`). If not specified, default path is `.`.

----

### Example
Expand All @@ -104,6 +108,7 @@ plugins:
locale: en
type: timeago
fallback_to_build_date: true
git_path: ./docs
```

Result:
Expand Down
5 changes: 4 additions & 1 deletion mkdocs_git_revision_date_localized_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ class GitRevisionDateLocalizedPlugin(BasePlugin):
("fallback_to_build_date", config_options.Type(bool, default=False)),
("locale", config_options.Type(str, default=None)),
("type", config_options.Type(str, default="date")),
("git_path", config_options.Type(str, default=".")),
)

def __init__(self):
self.util = Util()
pass

def on_config(self, config: config_options.Config) -> dict:
"""
Expand All @@ -37,6 +38,8 @@ def on_config(self, config: config_options.Config) -> dict:
dict: global configuration object
"""

self.util = Util(path=self.config.get("git_path", "."))

# Get locale settings - might be added in future mkdocs versions
# see: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/issues/24
mkdocs_locale = config.get("locale", None)
Expand Down