Skip to content

timeago is static #6

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

Closed
timvink opened this issue Dec 19, 2019 · 1 comment
Closed

timeago is static #6

timvink opened this issue Dec 19, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@timvink
Copy link
Owner

timvink commented Dec 19, 2019

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.

@timvink timvink added the bug Something isn't working label Dec 19, 2019
@timvink
Copy link
Owner Author

timvink commented Dec 20, 2019

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>

timvink added a commit that referenced this issue Dec 21, 2019
@timvink timvink closed this as completed Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant