Skip to content

Commit aad2448

Browse files
committed
feat(router): 添加自定义 robots.txt 支持
1 parent c5e7041 commit aad2448

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

config/config.yaml.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Web: # Web 页面修改相关设置
2424
<script src="/MediaWarp/custom/emby-front-end-mod/fanart-show.js"></script>
2525
<script src="/MediaWarp/custom/emby-front-end-mod/playbackRate.js"></script>
2626

27+
Robots: | # 自定义 robots.txt,若为空表示不修改
28+
User-agent: *
29+
Disallow: /
2730
Crx: True # crx 美化(Emby:https://github.com/Nolovenodie/emby-crx;Jellyfin:https://github.com/newday-life/jellyfin-crx)
2831
ActorPlus: True # 过滤没有头像的演员和制作人员
2932
FanartShow: False # 显示同人图(fanart 图)

internal/config/type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type WebSetting struct {
3737
Custom bool // 启用用户自定义静态资源
3838
Index bool // 是否从 custom 目录读取 index.html 文件作为首页
3939
Head string // 添加到 index.html 的 HEAD 中
40+
Robots string // 自定义 robots.txt,若为空表示不修改
4041
ExternalPlayerUrl bool // 是否开启外置播放器
4142
Crx bool // crx 美化
4243
ActorPlus bool // 过滤没有头像的演员和制作人员

internal/router/router.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ func InitRouter() *gin.Engine {
3838
if config.Web.Custom { // 用户自定义静态资源目录
3939
mediawarpRouter.Static("/custom", config.CostomDir())
4040
}
41+
if config.Web.Robots != "" { // 自定义 robots.txt
42+
mediawarpRouter.GET(
43+
"/robots.txt",
44+
func(ctx *gin.Context) {
45+
ctx.String(http.StatusOK, config.Web.Robots)
46+
},
47+
)
48+
}
4149
}
4250
}
4351

0 commit comments

Comments
 (0)