-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path404.html
104 lines (75 loc) · 1.98 KB
/
404.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!doctype html>
<head>
<meta charset="utf-8" />
<title>Grunt中文社区</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="/js/jquery-1.9.1.min.js"></script>
<script src="/js/markdown-js.js"></script>
<script src="/js/404router.js"></script>
<script src="/nav.js"></script>
<script>
$(function(){
// 路由
$404router.route('/:pageName',function(param){
if(!param.pageName) param.pageName = 'home';
var targetNav = nav.filter(function(navItem){
return navItem.url === param.pageName;
});
var docUrl;
if(targetNav.length){
document.title = targetNav[0].title + ' - Grunt中文社区';
}
if(targetNav.length){
docUrl = targetNav[0].doc;
}else{
docUrl = '/docs/' + param.pageName + '.md';
}
// 请求Markdown文档
$.get(docUrl).done(function(docText){
$('#content').html(markdown.toHTML(docText));
}).fail(function(xhr,errText,errObj){
if(xhr.status === 404){
$('#content').html(markdown.toHTML('# 404\n你要找的页面暂时失踪……'));
}
});
},function(statusCode){
$('#content').html(markdown.toHTML('# 404\n啊哦,路由出问题了,找不到回家的路了……'));
});
// 处理导航
if(window.nav && nav.length){
var navHtml = '';
nav.forEach(function(navItem){
navHtml += '<li><a href="/' + navItem.url + '">' + navItem.title + '</a></li>';
});
$('#mainNav ul').html(navHtml);
}
});
</script>
</head>
<body>
<header>
<div class="layout">
<div id="logo"></div>
<nav id="mainNav">
<ul>
</ul>
</nav>
</div>
</header>
<div class="layout">
<div id="content">
</div>
</div>
<footer>
<div class="layout">
<p>Grunt.js 中文社区为开源项目,由网友创建并维护。</p>
<p>
贡献者:
<a href="http://www.basecss.net" target="_blank">@Basecss</a>
<a href="http://www.toobug.net" target="_blank">@TooBug</a>
QQ群:16613475
</p>
</div>
</footer>
</body>
</html>