惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

记录生活,精彩一刻 - 学习

我又没忍住,又去找AI帮忙了,这次还好没翻车 我用AI写插件翻车了,留言区炸了,最近还是消停点吧 Typecho 插件推荐 UploadPlugin Typecho-Riven主题正式发售啦 小龙虾的“钳子”到底有什么用?聊聊OpenClaw的Skills 公众号规则改变运营挑战 OuonnkiTV:聚合影视平台推荐 截图神器KoalaSnap:一键搞定网页长图,隐私安全,完全免费 GKD - 安卓 去广告 神器 安装及使用教程 Rclone挂载WebDav为本地磁盘 阿里云推出 ESA 免费套餐 无需邀请开通 试试这款“Zen浏览器”,一种安静上网的新选择 Arc - 推荐一款浏览器,比较符合我个人的使用场景,同样也存在缺陷
Typecho 站内搜索插件 SiteSearch(BUG)
Huo · 2026-06-13 · via 记录生活,精彩一刻 - 学习

今天早上醒的特别早,也睡不着了,躺着也没啥意思,起来捣鼓博客吧,自从主题及系统升级完后一直还没测试过站内搜索的功能,尝试一下,结果发现问题,这篇文章做个记录。

这个问题不一定其它朋友遇到,但是我是真遇到了,这个博客永久链接地址设置了自定义地址 /archives/{slug}.html 。

搜索完成后,地址链接错误,给出的链接地址还是 https://9sb.net/archives/{slug}.html 不是真实的文章链接地址,随后找 AI 解决一下。

找到插件目录Action.php文件,找到原代码:

    private function formatResult($post, $matchType, $snippet = null)
{
    // 根据类型生成正确的URL
    $type = $post['type'];
    $cid = $post['cid'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    
    if ($type === 'page') {
        // 独立页面使用slug生成URL
        $url = Typecho_Router::url('page', array('cid' => $cid, 'slug' => $slug));
    } else {
        // 文章使用默认路由
        $url = Typecho_Router::url('post', array('cid' => $cid));
    }
    
    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

直接更换为:

    private function formatResult($post, $matchType, $snippet = null)
{
    $type = $post['type'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    $siteUrl = rtrim(Helper::options()->siteUrl, '/');

    if ($type === 'page') {
        // 独立页面沿用系统原生路由
        $url = Typecho_Router::url('page', array('cid' => $post['cid'], 'slug' => $slug));
    } else {
        // 文章强制适配自定义永久链接 /archives/{slug}.html
        $url = $siteUrl . '/archives/' . htmlspecialchars($slug) . '.html';
    }

    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

然后再去测试,问题已经解决,OK 收工。