Sha256: 08db1703203f9c7a05caee0d131da39d64754bee44e83d11675b977d78995d43

Contents?: true

Size: 1.87 KB

Versions: 2

Compression:

Stored size: 1.87 KB

Contents

<script src="https://cdn.jsdelivr.net/npm/dayjs/dayjs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs/plugin/customParseFormat.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dayjs/plugin/relativeTime.js"></script>
<script>
    $(document).ready(function () {
        var time_formats = ['YYYY-MM-DD HH:mm:ss ZZ', 'YYYY DD MMM HH:mm:ss ZZ', 'YYYY年MM月DD日 HH:mm:ss ZZ'];
        function dateFormat(date, format) {
            var date_org = dayjs(date, time_formats[format]);
            var date = date_org.format(time_formats[format]);
            return { "date_org": date_org, "date": date }
        }

        dayjs.extend(window.dayjs_plugin_customParseFormat);
        dayjs.extend(window.dayjs_plugin_relativeTime);
        var post_date = $("meta[property='post-date']").attr('content');
        var post_date_format = $("meta[property='post-date-format']").attr('content');
        var local_post_date = dateFormat(post_date, post_date_format);

        $(".post time span.create-at").html(local_post_date["date"]);

        fetch("https://api.github.com/repos/{{ site.github.owner }}/{{ site.github.repository }}/commits?path={{ page.path }}").then((response) => {
            return response.json();
        }).then((commits) => {
            if (commits.length != 0) {
                var update_at = dayjs(commits[0]['commit']['committer']['date']);
            } else {
                var update_at = post_date
            }

            var local_update_at = dateFormat(update_at, post_date_format);
            $('.post time span.update-at').html(local_update_at["date"]);

            var relative_time = dayjs().diff(local_update_at["date_org"], 'day');
            $(".post-copyright .tips span").append(relative_time);
            if (relative_time > 365) {
                $(".post-copyright .tips").addClass("active");
            }
        });
    });
</script>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-theme-h2o-ac-1.5.0 _includes/layouts/metainfo.html
jekyll-theme-h2o-ac-1.4.0 _includes/layouts/metainfo.html