-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
120 lines (116 loc) · 3.39 KB
/
index.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/index.css" />
<style>
/* 引入字体 */
@font-face {
font-family: "myFont";
src: url(./docs/MONACO.TTF);
}
* {
font-family: myFont,Source Sans Pro,Helvetica Neue,Arial,sans-serif !important;
}
</style>
</head>
<body>
<style>
.mini-sandbox {
margin: 20px 0;
border: 2px solid #b9d2ff;
border-radius: 5px;
box-shadow: 0 2px 12px 0 rgba(94, 144, 232, 0.5);
}
</style>
<div id="app"></div>
<script>
window.$docsify = {
name: '',
repo: 'buuing/mini-sandbox',
// 自定义侧边栏
loadSidebar: true,
// 抓取目录渲染
maxLevel: 3,
subMaxLevel: 3,
// 开启封面页
coverpage: false,
// 切换页面后跳到顶部
auto2top: true,
// 路由
alias: {
'/.*/_sidebar.md': '/_sidebar.md',
},
executeScript: true,
plugins: [
function(hook) {
hook.afterEach(function(html, next) {
next(html.replace(/\^\^\^/gm, (res, ...arg) => '```'))
})
},
function(hook) {
hook.beforeEach(function(content) {
return content.replace(/\$\{version\}/gm, (res, ...arg) => '0.3.11')
})
},
function(hook) {
let arr = []
hook.beforeEach(function(content) {
arr = []
content.replace(/<script type\=\"text\/javascript\">(.*?)<\/script>\n```/gms, (res, script) => {
arr.push(script)
})
})
hook.afterEach(function(html, next) {
if (!arr.length) return next(html)
const scriptStr = `\n<script>\n${arr.join('\n')}\n<\/script>\n`
next(html + scriptStr)
})
},
],
// 全局默认配置
sandboxOptions: {
defaultConfig: {
height: '300px',
autoRun: true,
},
},
}
// sandbox 配置项
window.Demo1Config = {
css: `
.box {
width: 100px;
height: 100px;
background: green;
position: absolute;
}
`,
js: `
const box = document.querySelector('div')
setInterval(() => {
const left = Math.sin(Date.now() / 500) * 100 + 100
box.style.left = left + 'px'
}, 1000 / 60)
`
}
</script>
<!-- Docsify v4 -->
<script src="./docs/docsify.js"></script>
<script src="./docs/prism-bash.js"></script>
<!-- 下面的用于本地开发 -->
<!-- <script src="./dist/index.umd.js"></script>
<script src="./dist/docsify-plugin.js"></script>
<script src="./dist/vue-loader.js"></script>
<script src="./dist/react-loader.js"></script> -->
<!-- 下面的用于线上 -->
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/[email protected]/dist/docsify-plugin.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue-loader.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-loader.js"></script>
</body>
</html>