From b31636072338d2879b528258de8accf4a66c68d3 Mon Sep 17 00:00:00 2001 From: <> Date: Sun, 18 Feb 2024 11:51:10 +0000 Subject: Deployed 9b916be with MkDocs version: 1.5.3 --- js/timeago_mkdocs_material.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 js/timeago_mkdocs_material.js (limited to 'js/timeago_mkdocs_material.js') 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); + } +} -- cgit v1.2.3-70-g09d2