-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Revision date doesn't work with Instant loading #1918
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
Comments
Thanks for reporting! Might I ask you to test whether this also happens with the non-localized version of revision date? |
Sorry for the delay @squidfunk, I've been outside for the whole day. I've just tested the non-localized version, and it works just fine. The problem seems to appear only in the localized version. |
No worries. Thanks for your efforts! I'm going to CC @timvink here, as he's the author of the extension. Does the extension inject any JavaScript when |
Yes, it includes timeago.js and some CSS to enable dynamically updating the timeago. (see https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/master/mkdocs_git_revision_date_localized_plugin/plugin.py#L112-L126)
I'm aware of this behaviour. I actually have a similar issue with instant loading not working for another plugin I wrote (mkdocs-print-site-plugin) that also injects some javascript. I'm not sure if making that work with instant loading is a bug, or something that's just not possible. @squidfunk Any advice on how to include javascript that will be compatible with instant loading? I would be happy to work on a fix but I'm not very experienced with javascript so I need some pointers.. |
@timvink thanks for your input! It's not hard to get it working with instant loading. The documentation describes how to integrate
extra_javascript:
- https://cdnjs.cloudflare.com/ajax/libs/tablesort/5.2.1/tablesort.min.js
- javascripts/tables.js
app.document$.subscribe(function() {
var tables = document.querySelectorAll("article table")
tables.forEach(function(table) {
new Tablesort(table)
})
}) As instant loading is a Material-specific feature, you'd have to detect Material. The if (
typeof app !== "undefined" &&
typeof app.document$ !== "undefined"
) {
app.document$.subscribe(function() {
// custom logic
})
}
... Other than that, you may also use the if (document.querySelector("meta[name=generator][content*=mkdocs-material]")) {
// custom logic
} |
I'm closing this issue, as it's a problem originating from the revision date plugin, not Material for MkDocs itself. If you need further assistance, feel free to come back to this issue. |
Sweet thanks for the help @squidfunk, and thanks for the detailed report @danierutu ! I just released |
Uh oh!
There was an error while loading. Please reload this page.
I checked that...
Description
When I set the
instant
feature along with thegit-revision-date-localized
plugin and click in any page from within the site, the XHR reload shows the new page fast, but the revision date won't appear at the end. I can only see it by refresing the site.This bug doesn't happen when I follow a link to the site; only when I navigate through pages from within the site (XHR reloads).
Expected behavior
Go to another page, displayed by XHR, and see the revision date at the end.
Actual behavior
Go to another page, displayed by XHR, and only see "Last update:", without any date.
Steps to reproduce the bug
instant
andgit-revision-date-localized
:Package versions
(although it also happened before using Insider builds)
Project configuration
System information
The text was updated successfully, but these errors were encountered: