Skip to content

Commit

Permalink
添加文章「最近修改日期」
Browse files Browse the repository at this point in the history
  • Loading branch information
林靖清 committed Aug 1, 2021
1 parent c402044 commit b4b3405
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,19 @@
plugins: [
function (hook, vm) {
hook.beforeEach(function (html) {
var url = 'https://github.com/JingqingLin/blog/blob/master/docs/' + vm.route.file;
var edit_url = 'https://github.com/jingqinglin//blog/blob/master/docs/' + vm.route.file;
var date_url = 'https://api.github.com/repos/jingqinglin/blog/commits?per_page=1&path=docs/' + vm.route.file;
fetch(date_url)
.then((response) => {
return response.json();
})
.then((commits) => {
var modified = commits[0]['commit']['committer']['date'].slice(0, 10);
document.getElementById('last-modified').textContent = "上次修改:" + modified;
});
return (
'<div class="edit-document" style="font-size: 14px;" align="right">✏️ <a style="font-weight: 400" href=' + url + ' target="_blank">编辑文档</a></div>' +
'\n\n' +
'<div class="edit-document" style="font-weight: bold;"><span id="last-modified" style="float: right;"></span><span>✏️ <a style="text-decoration: none;color: inherit;" href=' + edit_url + ' target="_blank">在 GitHub 上编辑此页</a></span></div>' +
'<hr>\n\n' +
html
);
});
Expand Down

1 comment on commit b4b3405

@vercel
Copy link

@vercel vercel bot commented on b4b3405 Aug 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.