Skip to content

Commit 34c98e6

Browse files
authored
Update index.html
1 parent 1bcb025 commit 34c98e6

File tree

1 file changed

+147
-30
lines changed

1 file changed

+147
-30
lines changed

index.html

Lines changed: 147 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,154 @@
11
<!DOCTYPE html>
2-
<html lang="zh-CN">
3-
<head>
4-
<meta charset="UTF-8">
5-
<title>Docsify 最小化测试</title>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>JavaGuide</title>
66
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
8-
<link rel="stylesheet" href="https://unpkg.com/docsify/lib/themes/vue.css">
9-
</head>
10-
<body>
11-
<div id="docsify-app-container">页面正在努力加载中...</div> <!-- 修改了ID并添加了初始文本 -->
7+
<meta name="description" content="Description" />
8+
<meta
9+
name="viewport"
10+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
11+
/>
12+
<!--主题-->
13+
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css" />
14+
</head>
15+
16+
<body>
17+
<nav>
18+
<a href="hhttps://javaguide.cn/zhuanlan/java-mian-shi-zhi-bei.html"
19+
>Java面试指北</a>
20+
<a href="https://javaguide.cn/about-the-author/zhishixingqiu-two-years.html"
21+
>知识星球</a
22+
>
23+
</nav>
24+
<div id="app"></div>
25+
26+
<!-- docsify-edit-on-github (需要放在 docsify 脚本之前,因为它修改的是 $docsify 配置) -->
27+
<script src="//unpkg.com/docsify-edit-on-github/index.js"></script>
1228

1329
<script>
14-
console.log('[MINIMAL TEST A] window.$docsify 配置脚本块开始执行。');
15-
16-
window.$docsify = {
17-
el: '#docsify-app-container', // 显式指定挂载元素
18-
name: '最小化测试文档 A',
19-
// homepage: 'README.md', // 可以显式指定首页文件,如果你的文件不叫 README.md
20-
doneEach: function(html, next) {
21-
console.log('[MINIMAL TEST A] doneEach 钩子成功触发! HTML content received.');
22-
// 为了确认是否真的有内容被处理,可以打印一下html的开头部分
23-
// console.log('[MINIMAL TEST A] HTML snippet:', String(html).substring(0, 100));
24-
next(html);
25-
},
26-
// 新增一个 ready 钩子,看它是否会触发
27-
ready: function() {
28-
console.log('[MINIMAL TEST A] Docsify "ready" 钩子触发!');
29-
}
30-
};
31-
32-
console.log('[MINIMAL TEST A] window.$docsify 对象已定义完毕:', window.$docsify);
30+
// 离线支持
31+
if (typeof navigator.serviceWorker !== "undefined") {
32+
navigator.serviceWorker.register("sw.js");
33+
}
34+
35+
window.$docsify = {
36+
name: "JavaGuide",
37+
repo: "https://github.com/Snailclimb/JavaGuide",
38+
maxLevel: 4, //最大支持渲染的标题层级
39+
//封面,_coverpage.md
40+
//coverpage: true,
41+
auto2top: true, //切换页面后是否自动跳转到页面顶部
42+
//ga: 'UA-138586553-1',
43+
//logo: 'https://my-blog-to-use.oss-cn-beijing.aliyuncs.com/2019-3logo-透明.png' ,
44+
search: {
45+
//maxAge: 86400000, // 过期时间,单位毫秒,默认一天
46+
paths: "auto",
47+
placeholder: "搜索",
48+
noData: "找不到结果",
49+
// 搜索标题的最大程级, 1 - 6
50+
depth: 3,
51+
},
52+
// 备案
53+
beian: {
54+
ICP: "鄂ICP备2020015769号",
55+
NISMSP: {
56+
number: "",
57+
url: "",
58+
id: "",
59+
},
60+
},
61+
// 字数统计
62+
count: {
63+
countable: true,
64+
fontsize: "0.9em",
65+
color: "rgb(90,90,90)",
66+
language: "chinese",
67+
},
68+
69+
// =========== Plugins Configuration ===========
70+
plugins: [
71+
// Existing EditOnGithubPlugin
72+
EditOnGithubPlugin.create(
73+
"https://github.com/Snailclimb/JavaGuide/blob/master/"
74+
),
75+
76+
// --- Plugin for Image Hotlink Protection (from previous request) ---
77+
function (hook) {
78+
const targetOrigin = 'https://oss.javaguide.cn/';
79+
const antiHotlinkParamKeyVal = 'x-oss-process=style/javaguide'; // <-- Adjust this parameter as needed
80+
81+
hook.afterEach(function (html, next) {
82+
const imgRegex = new RegExp(`<img[^>]*src="(https?:\\/\\/oss\\.javaguide\\.cn\\/[^"]*)"[^>]*>`, 'gi');
83+
84+
let modifiedHtml = html.replace(imgRegex, function(match, srcUrl) {
85+
if (srcUrl.includes(antiHotlinkParamKeyVal)) {
86+
return match;
87+
}
88+
const separator = srcUrl.includes('?') ? '&' : '?';
89+
const newSrcUrl = srcUrl + separator + antiHotlinkParamKeyVal;
90+
return match.replace(srcUrl, newSrcUrl);
91+
});
92+
// Note: This plugin now adds referrerpolicy as well. You could combine
93+
// the logic here, or keep it separate in the next plugin.
94+
// Keeping it separate for clarity in demonstrating the new requirement.
95+
96+
next(modifiedHtml);
97+
});
98+
},
99+
// --- End Plugin for Image Hotlink Protection ---
100+
101+
102+
// --- New Plugin to Add referrerpolicy="no-referrer" to ALL Images ---
103+
function (hook) {
104+
hook.afterEach(function (html, next) {
105+
// Regex to find all img tags globally and case-insensitively
106+
const imgTagRegex = /<img[^>]*>/gi;
107+
let modifiedHtml = html.replace(imgTagRegex, function(match) {
108+
// Check if referrerpolicy attribute is already present (case-insensitive)
109+
if (match.toLowerCase().includes('referrerpolicy=')) {
110+
return match; // Attribute already exists, return original match
111+
}
112+
// Add the attribute right before the closing '>'
113+
// This replaces the last '>' with the attribute and '>'
114+
return match.replace(/>$/, ' referrerpolicy="no-referrer">');
115+
});
116+
117+
next(modifiedHtml);
118+
});
119+
}
120+
// --- End New Plugin ---
121+
122+
],
123+
// ===========================================
124+
};
33125
</script>
34126

35-
<script src="https://unpkg.com/docsify/lib/docsify.min.js"></script>
36-
</body>
127+
<!-- Main Docsify script (必须在配置脚本之后) -->
128+
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
129+
130+
<!-- 其他 Docsify 插件 (通常在主 docsify 脚本之后) -->
131+
<!--Java代码高亮-->
132+
<script src="//unpkg.com/prismjs/components/prism-java.js"></script>
133+
<!--全文搜索,直接用官方提供的无法生效-->
134+
<script src="https://cdn.bootcss.com/docsify/4.5.9/plugins/search.min.js"></script>
135+
<!--谷歌统计
136+
<script src="//unpkg.com/docsify" data-ga="UA-138586553-1"></script>
137+
<script src="//unpkg.com/docsify/lib/plugins/ga.js"></script>
138+
-->
139+
<!-- 复制到剪贴板 -->
140+
<script src="//unpkg.com/docsify-copy-code"></script>
141+
<!-- 图片缩放 -->
142+
<script src="//unpkg.com/docsify/lib/plugins/zoom-image.js"></script>
143+
<!-- 表情 -->
144+
<script src="//unpkg.com/docsify/lib/plugins/emoji.js"></script>
145+
<!-- 字数统计 -->
146+
<script src="//unpkg.com/docsify-count/dist/countable.js"></script>
147+
<!-- 备案 -->
148+
<script src="https://cdn.jsdelivr.net/npm/docsify-beian@latest/dist/beian.min.js"></script>
149+
150+
<!-- 如果你需要 MathJax,请在此处或 <head> 中引入 -->
151+
<!-- <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" async></script> -->
152+
153+
</body>
37154
</html>

0 commit comments

Comments
 (0)