Closed timvink closed 4 years ago
I can implement this without asking the user to configure anything. Rough plan:
When config has type: timeago
the {{ git_revision_date_localized }}
tag should produce a tag like
<div class="timeago" datetime="2016-06-30 09:20:00"></div>
Then I could use on_page_content
to insert some javascript at the bottom of the page before </body>
, like
<!-- Get latest version from https://cdnjs.com/libraries/timeago.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.0-beta.2/timeago.locales.min.js" type="text/javascript"></script>
<script>
const nodes = document.querySelectorAll('.timeago');
timeago.render(nodes, 'nl');
</script>
I optimistically added the
type: timeago
option, but only now realise this is fixed after building and thus quite static (unless you rebuild your website very regularly..)Either I should remove the type, or update README to explain how to use timeago.js with
mkdocs
.