Skip to content

Commit c87530c

Browse files
committed
Add support for mkdocs-material instant loading feature
1 parent d4a37e1 commit c87530c

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

Diff for: mkdocs_git_revision_date_localized_plugin/plugin.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,20 @@ def on_post_page(self, output_content: str, **kwargs) -> str:
162162
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.min.js"></script>
163163
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.locales.min.js"></script>
164164
<script>
165-
var nodes = document.querySelectorAll('.timeago');
166-
var locale = nodes[0].getAttribute('locale');
167-
timeago.render(nodes, locale);
165+
if (
166+
typeof app !== "undefined" &&
167+
typeof app.document$ !== "undefined"
168+
) {
169+
app.document$.subscribe(function() {
170+
var nodes = document.querySelectorAll('.timeago');
171+
var locale = nodes[0].getAttribute('locale');
172+
timeago.render(nodes, locale);
173+
})
174+
} else {
175+
var nodes = document.querySelectorAll('.timeago');
176+
var locale = nodes[0].getAttribute('locale');
177+
timeago.render(nodes, locale);
178+
}
168179
</script>
169180
"""
170181
idx = output_content.index("</body>")

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="mkdocs-git-revision-date-localized-plugin",
8-
version="0.7",
8+
version="0.7.1",
99
description="Mkdocs plugin that enables displaying the localized date of the last git modification of a markdown file.",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
site_name: test gitrevisiondatelocalized_plugin
2+
use_directory_urls: true
3+
4+
theme:
5+
name: 'material'
6+
features:
7+
- instant
8+
9+
plugins:
10+
- search
11+
- git-revision-date-localized:
12+
type: timeago

0 commit comments

Comments
 (0)