diff options
Diffstat (limited to 'js/timeago_mkdocs_material.js')
| -rw-r--r-- | js/timeago_mkdocs_material.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/timeago_mkdocs_material.js b/js/timeago_mkdocs_material.js new file mode 100644 index 0000000..b3c8cdf --- /dev/null +++ b/js/timeago_mkdocs_material.js @@ -0,0 +1,18 @@ +// Script to ensure timeago keeps working when +// used with mkdocs-material's instant loading feature + +if (typeof document$ !== "undefined") { + document$.subscribe(function() { + var nodes = document.querySelectorAll('.timeago'); + if (nodes.length > 0) { + var locale = nodes[0].getAttribute('locale'); + timeago.render(nodes, locale); + } + }) +} else { + var nodes = document.querySelectorAll('.timeago'); + if (nodes.length > 0) { + var locale = nodes[0].getAttribute('locale'); + timeago.render(nodes, locale); + } +} |
