支持自动转换相对链接 (#324)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
neveler 2025-11-07 18:26:28 +08:00 committed by GitHub
parent 47f39cd9d9
commit 390bc2a1b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 54 additions and 19 deletions

View File

@ -1,8 +1,8 @@
---
layout: splash
---
<div class="notice--danger">
<h1 id="">404</h1>
<p><strong>页面不存在</strong></p>
</div>
---
layout: splash
---
<div class="notice--danger">
<h1 id="">404</h1>
<p><strong>页面不存在</strong></p>
</div>

View File

@ -30,3 +30,7 @@ end
gem "wdm", "0.2.0", :platforms => [:windows]
gem "http_parser.rb", "0.8.0", :platforms => [:jruby]
# plugin dependencies
gem "nokogiri", "1.18.10"
gem "addressable", "2.8.7"

View File

@ -6,4 +6,4 @@ author: huanghongxun
如果你认为你有能力为 HMCL 添加高质量的帮助文档,或希望修改错误,你可以到 [https://github.com/HMCL-dev/HMCL-docs](https://github.com/HMCL-dev/HMCL-docs) 仓库中发 Pull Request或者提 Issue。
或者你可以进入我们的 [Discord](https://discord.gg/jVvC7HfM6U) 或 [HMCL 用户群](/groups.html) 群以向 HMCL 反馈。
或者你可以进入我们的 [Discord](https://discord.gg/jVvC7HfM6U) 或 [HMCL 用户群](/_docs/groups.md) 群以向 HMCL 反馈。

View File

@ -78,15 +78,15 @@ contributors:
- [CurseForge](https://www.curseforge.com/minecraft/search?class=mc-mods)
- [Modrinth](https://modrinth.com/mods)
HMCL 自动安装与使用模组教程: [跳转](/launcher/auto-installing.html)
HMCL 自动安装与使用模组教程: [跳转](/_launcher/auto-installing.md)
#### 安装模组后游戏报错怎么办
安装模组后游戏无法启动或崩溃是常见的情况,通常是模组冲突或缺少前置模组导致的。别担心,大部分问题都能轻松解决。
在 HMCL《自动安装与模组下载简介》的末尾讲到了常用的解决方法 [跳转](/launcher/auto-installing.html#%E5%AE%89%E8%A3%85-mod-%E5%90%8E%E6%B8%B8%E6%88%8F%E6%8A%A5%E9%94%99%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8)
在 HMCL《自动安装与模组下载简介》的末尾讲到了常用的解决方法 [跳转](/_launcher/auto-installing.md#安装-mod-后游戏报错无法启动)
或者前往模组包报错排查手册中查看: [跳转](/modpack/error-handbook.html)
或者前往模组包报错排查手册中查看: [跳转](/_modpack/error-handbook.md)
如果无法解决错误,尝试 [寻求帮助](help.html)

View File

@ -31,7 +31,7 @@ contributors:
## 报错崩溃交流群
如果你遇到了游戏非正常退出问题,欢迎加入报错崩溃交流群咨询解决方案:[Minecraft 报错崩溃交流群](/crash-support-group.html)
如果你遇到了游戏非正常退出问题,欢迎加入报错崩溃交流群咨询解决方案:[Minecraft 报错崩溃交流群](/_docs/crash-support-group.md)
**本群仅处理游戏报错崩溃问题,无关话题请前往其他群聊讨论。**

View File

@ -8,7 +8,7 @@ author: zkitefly
Hello Minecraft! Launcher 的官方 QQ 群聊。
[点击前往](/groups.html)
[点击前往](/_docs/groups.md)
## Discord 频道

View File

@ -68,7 +68,7 @@ HMCL 内置了 CurseForge 和 Modrinth 下载源的搜索和下载功能, 目前
#### OptiFine
[详情请查阅此](/launcher/shader.html)
[详情请查阅此](/_launcher/shader.md)
### 手动安装

View File

@ -54,7 +54,7 @@ OptiFine [页面](https://optifine.net/downloads) 操作:
OptiFine 非官方 [中文页面](https://optifine.cn/downloads) 操作:
![OptiFine非官方中文页面操作](/assets/img/docs/fabric_and_optifine_install/3.png)
<!-- ![OptiFine非官方中文页面操作](/assets/img/docs/fabric_and_optifine_install/3.png) -->
#### 安装

View File

@ -42,7 +42,7 @@ contributors:
### 方式四OptiFine 与 Mod 加载器共存
从[ OptiFine 官网](https://www.optifine.net/)上下载的 Jar 文件本身也可作为 Mod 被加载,可以用 Java 运行下载的文件并导出 Mod 版本。Mod 安装具体方法见 [ Mod 安装教程](auto-installing.html)
从[ OptiFine 官网](https://www.optifine.net/)上下载的 Jar 文件本身也可作为 Mod 被加载,可以用 Java 运行下载的文件并导出 Mod 版本。Mod 安装具体方法见 [ Mod 安装教程](/_launcher/auto-installing.md)
注意:

View File

@ -41,7 +41,7 @@ author: LIPiston
...
```
我们极力推荐您打开版本隔离,因为这样能避免模组之间的一部分冲突 [跳转](/launcher/global-version-isolation.html)
我们极力推荐您打开版本隔离,因为这样能避免模组之间的一部分冲突 [跳转](/_launcher/isolation.md)
## 简单排查

View File

@ -4,7 +4,7 @@ date: 2023-01-11 14:13:45 +0800
author: buggzd
---
> 阅读本文前,请先阅读[此文章](/modpack/serverpack.html)
> 阅读本文前,请先阅读[此文章](/_modpack/serverpack.md)
# 前置知识

31
_plugins/auto-link.rb Normal file
View File

@ -0,0 +1,31 @@
require "nokogiri"
require "addressable/uri"
Jekyll::Hooks.register [:pages, :documents], :post_convert do |doc|
next unless doc.output_ext == ".html"
site = doc.site
baseurl = site.config["baseurl"].to_s
liquid_context = Liquid::Context.new({}, {}, { site: site })
process_uri = lambda do |path|
uri = Addressable::URI.parse(path)
if uri&.path && !uri.path&.start_with?(baseurl)
uri.path = Liquid::Template.parse("{% link #{uri.path[1..]} %}").render!(liquid_context)
end
uri.to_s
end
fragment = Nokogiri::HTML::DocumentFragment.parse(doc.content)
fragment.css("[src^=\"/\"]").each do |item|
if item["src"]
item["src"] = process_uri.call(item["src"])
end
end
fragment.css("[href^=\"/\"]").each do |item|
if item["href"]
item["href"] = process_uri.call(item["href"])
end
end
doc.content = fragment.to_html
end