Skip to content

Commit 66e2820

Browse files
committed
'初次基本开发完成'
1 parent fd9b4ca commit 66e2820

29 files changed

+6075
-259
lines changed

.babelrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": [
3+
[
4+
"import",
5+
{
6+
"libraryName": "iview",
7+
"libraryDirectory": "src/components"
8+
}
9+
]
10+
]
11+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ npm-debug.log*
2323
yarn-debug.log*
2424
yarn-error.log*
2525

26+
# font file and svg
27+
hexo-history-main.js
28+
.woff2
29+
.woff
30+
.svg
31+
.ttf
80.3 KB
Binary file not shown.

99ac3308dd8ee14f749f51538d0d5b9e.woff

193 KB
Binary file not shown.

a2c4a261a239aa84463dc70e4bac9b9a.svg

+870
Loading

d535a25a79fb1365ae814b61e88fae71.ttf

193 KB
Binary file not shown.

index.html

+345
Large diffs are not rendered by default.

index.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
const fs = require('hexo-fs');
22

3-
const scriptUrl = '/post-history/main.js';
4-
var config = hexo.config.history;
3+
var config = hexo.config.history || {};
54
function buildGenerator(sourcePath, distPath) {
65
return {
76
data: () => fs.createReadStream(sourcePath),
87
path: distPath
98
};
109
}
1110
//将打包好后的main复制到public中
12-
hexo.extend.generator.register('test', () => {
13-
return buildGenerator(require.resolve('./dist/main.js'), scriptUrl);
11+
hexo.extend.generator.register('hexo-history-file', () => {
12+
return [
13+
{ entry: './hexo-history-main.js', out: '/hexo-history-main.js' },
14+
{
15+
entry: './143146fa24554ae2c5ac0a3982abb952.woff2',
16+
out: '/143146fa24554ae2c5ac0a3982abb952.woff2'
17+
}
18+
].map((i) => buildGenerator(require.resolve(i.entry), i.out));
1419
});
1520
//添加上script标签
1621
hexo.extend.filter.register('after_render:html', (htmlContent) => {
17-
const scriptToInject = `hexoHistory.init(${JSON.stringify(config)});`;
18-
const contentToInject = `<script src="${scriptUrl}"></script><script>${scriptToInject}</script>`;
22+
const scriptToInject = `HexoHistory(${JSON.stringify(config)});`; //把配置注册为全局变量好了
23+
let vueInject = `<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>`;
24+
const contentToInject = `${vueInject}<script src="/hexo-history-main.js"></script><script>${scriptToInject}</script>`;
1925
let newHtmlContent = htmlContent;
2026
if (/([\n\r\s\t]*<\/body>)/i.test(htmlContent)) {
2127
const lastIndex = htmlContent.lastIndexOf('</body>');

0 commit comments

Comments
 (0)