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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

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

我又没忍住,又去找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 收工。