Skip to content

Commit

Permalink
Add support for mkdocs-material instant loading feature
Browse files Browse the repository at this point in the history
  • Loading branch information
timvink committed Sep 13, 2020
1 parent d4a37e1 commit c87530c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
17 changes: 14 additions & 3 deletions mkdocs_git_revision_date_localized_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,20 @@ def on_post_page(self, output_content: str, **kwargs) -> str:
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.locales.min.js"></script>
<script>
var nodes = document.querySelectorAll('.timeago');
var locale = nodes[0].getAttribute('locale');
timeago.render(nodes, locale);
if (
typeof app !== "undefined" &&
typeof app.document$ !== "undefined"
) {
app.document$.subscribe(function() {
var nodes = document.querySelectorAll('.timeago');
var locale = nodes[0].getAttribute('locale');
timeago.render(nodes, locale);
})
} else {
var nodes = document.querySelectorAll('.timeago');
var locale = nodes[0].getAttribute('locale');
timeago.render(nodes, locale);
}
</script>
"""
idx = output_content.index("</body>")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="mkdocs-git-revision-date-localized-plugin",
version="0.7",
version="0.7.1",
description="Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/basic_project/mkdocs_theme_timeago_instant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
site_name: test gitrevisiondatelocalized_plugin
use_directory_urls: true

theme:
name: 'material'
features:
- instant

plugins:
- search
- git-revision-date-localized:
type: timeago

0 comments on commit c87530c

Please sign in to comment.