-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.js
76 lines (73 loc) · 3.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* Hexo Github Canlendar
* Ice Kano
* Modify: Lete乐特
*/
'use strict'
function priority_githubcalendar(){
var priority = 0
if(hexo.config.githubcalendar.priority){
priority = hexo.config.githubcalendar.priority
}
else{
priority = 0
}
return priority
}
var priority = 0
hexo.extend.filter.register('after_generate',function(){
var config = this.config;
var github_calendar = config.githubcalendar.enable;
if (github_calendar){
var calendar_enable_page = config.githubcalendar.enable_page;
var calendar_js = config.githubcalendar.calendar_js;
var github_color = config.githubcalendar.color;
var layout_name ='';
var layout_type ='';
var layout_index =0;
if(config.githubcalendar.layout_id){
layout_name = config.githubcalendar.layout_id;
layout_type = 'id';
}else{
layout_name = config.githubcalendar.layout.name;
layout_type = config.githubcalendar.layout.type;
layout_index = config.githubcalendar.layout.index;
}
var get_layout = ''
if (layout_type == 'class'){
get_layout = `document.getElementsByClassName('${layout_name}')[${layout_index}]`
}else if (layout_type == 'id'){
get_layout = `document.getElementById('${layout_name}')`
}else {
get_layout = `document.getElementById('${layout_name}')`
}
var plus_style = config.githubcalendar.plus_style;
var githubcalendar_html = config.githubcalendar.githubcalendar_html;
var github_user = config.githubcalendar.user;
var github_api = config.githubcalendar.api;
var pc_minheight = config.githubcalendar.pc_minheight;
var mobile_minheight = config.githubcalendar.mobile_minheight;
var user_info_js = `
<script data-pjax src="${calendar_js}"></script>
<script data-pjax>
function GithubCalendarConfig(){
var git_githubapiurl ="${github_api}?${github_user}";
var git_color =${github_color};
var git_user ="${github_user}";
var parent_div_git = ${get_layout};
var git_div_html = '${githubcalendar_html}';
if(parent_div_git && location.pathname =='${calendar_enable_page}'){
console.log('已挂载github calendar')
// parent_div_git.innerHTML=git_div_html+parent_div_git.innerHTML // 无报错,但不影响使用(支持pjax跳转)
parent_div_git.insertAdjacentHTML("afterbegin",git_div_html) // 有报错,但不影响使用(支持pjax跳转)
};
GithubCalendar(git_githubapiurl,git_color,git_user)
}
if(${get_layout}){
GithubCalendarConfig()
}
</script>
<style>#github_container{min-height:${pc_minheight}}@media screen and (max-width:650px) {#github_container{background-image:;min-height:${mobile_minheight}}}</style>
<style>${plus_style}</style>`
hexo.extend.injector.register('body_end',user_info_js, "default");
}},priority_githubcalendar())