<script>
    /**
     * Taken from <a href=https://github.com/ryanfb/etc/blob/4d24f757183e0fff83d95e42131f04124dab8896/_layouts/default.html#L34-L47>
     *     Last Modified Dates for GitHub Pages Jekyll Posts</a>, under CC BY 4.0
     * @author Ryan Baumann
     */
    function setModifiedDate() {
        if (document.getElementById('last-modified')) {
            fetch("https://api.github.com/repos/Fabilin/{{ site.github.repository_name }}/commits?sha=doc/jekyll&path=docs/{{ page.path }}")
                .then((response) => {
                    return response.json();
                })
                .then((commits) => {
                    const modified = commits[0]['commit']['committer']['date'].slice(0, 10);
                    if(modified !== '{{ page.date | date: "%Y-%m-%d" }}') {
                        document.getElementById('last-modified').textContent = `{{include.label}}${modified}`;
                    }
                });
        }
    }
    setModifiedDate()
</script>