From 913b5eaad25b9ba1cf0ad8d9b25633ec454c74e5 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Thu, 27 Jul 2023 13:59:52 +0800 Subject: first push --- docs/site/js/timeago_mkdocs_material.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/site/js/timeago_mkdocs_material.js (limited to 'docs/site/js/timeago_mkdocs_material.js') diff --git a/docs/site/js/timeago_mkdocs_material.js b/docs/site/js/timeago_mkdocs_material.js new file mode 100644 index 00000000..b3c8cdf8 --- /dev/null +++ b/docs/site/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