diff --git a/README.md b/README.md index 597c9dc..d557f0f 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ hexo_safego: - '#article-container' domain_whitelist: # 域名白名单列表,包含白名单中的域名的链接将被忽略 - 'qyliu.top' + exclude_pages: + - 'fcircle/index.html' apply_pages: # 生效页面路径列表,只有在这些页面上才会对链接进行处理 - '/posts/' avatar: /info/avatar.ico # 头像图片链接 @@ -140,4 +142,4 @@ hexo_safego: ### 问题反馈 -如果有任何问题,请提 issue 或者联系作者邮箱 01@liushen.fun,或者在网站中进行提问:https://blog.qyliu.top \ No newline at end of file +如果有任何问题,请提 issue 或者联系作者邮箱 01@liushen.fun,或者在网站中进行提问:https://blog.qyliu.top diff --git a/index.js b/index.js index 7196556..af0fb39 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const config = hexo.config.hexo_safego = Object.assign({ ignore_attrs: ['data-fancybox'], apply_containers: ['#article-container'], // 容器列表,如果为空则匹配整个body apply_pages: ['/posts/'], // 生效页面路径列表 + exclude_pages: ['/link/index.html'], // 排除页面路径列表 domain_whitelist: ["example.com"], // 域名白名单列表 darkmode: false, // 设置为true为暗色模式 avatar: "https://fastly.jsdelivr.net/gh/willow-god/hexo-safego@latest/lib/avatar.png", @@ -37,6 +38,18 @@ if (config.enable) { console.log("[hexo-safego]", "当前页面路径:", currentPath); } + const isPathInExcludePages = Array.isArray(config.exclude_pages) && config.exclude_pages.some(page => { + const normalizedPage = '/' + page.replace(/^\//, ''); + return currentPath.startsWith(normalizedPage); + }); + + if (isPathInExcludePages) { + if (config.debug) { + console.log("[hexo-safego]", "当前页面路径在 exclude_pages 列表中,跳过链接处理。"); + } + return htmlContent; + } + const applyPages = Array.isArray(config.apply_pages) && config.apply_pages.length > 0 ? config.apply_pages : ["/"]; const isPathInApplyPages = applyPages.some(page => { const normalizedPage = '/' + page.replace(/^\//, ''); // 确保 page 以斜杠开头