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

推荐订阅源

J
Java Code Geeks
小众软件
小众软件
博客园 - 叶小钗
宝玉的分享
宝玉的分享
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
B
Blog RSS Feed
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
U
Unit 42
F
Fortinet All Blogs
IT之家
IT之家
Y
Y Combinator Blog
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
Stack Overflow Blog
Stack Overflow Blog
Blog — PlanetScale
Blog — PlanetScale
酷 壳 – CoolShell
酷 壳 – CoolShell

二丫讲梵

学习周刊-总第258期-2026年第15周 学习周刊-总第257期-2026年第14周 学习周刊-总第256期-2026年第13周 学习周刊-总第255期-2026年第12周 学习周刊-总第254期-2026年第11周 学习周刊-总第253期-2026年第10周 临时插播一条羊毛,免费领取450元大模型API代金券 学习周刊-总第252期-2026年第09周 学习周刊-总第251期-2026年第08周 学习周刊-总第250期-2026年第07周 学习周刊-总第249期-2026年第06周 诚邀评论,聊聊你所知欲知的我 学习周刊-总第248期-2026年第05周 我的QQ动态之2015年 我的QQ动态之2014年 我的QQ动态之2013年 我的QQ动态之2012年 我的QQ动态-2010-2011年 我的QQ动态-创栏小叙 学习周刊-总第247期-2026年第04周 Nexus社区版权益阉割--一文告诉你有哪些版本可以选择 学习周刊-总第246期-2026年第03周 学习周刊-总第245期-2026年第02周 学习周刊-总第244期-2026年第01周 学习周刊-总第243期-2025年第52周 学习周刊-总第242期-2025年第51周 开源项目ZenOps:带你领略禅意运维 学习周刊-总第241期-2025年第50周 用京东金融,享负债人生 学习周刊-总第240期-2025年第49周
Vuepress全文搜索插件vuepress-plugin-flexsearch-pro
二丫讲梵 · 2023-02-09 · via 二丫讲梵

# 前言

之前介绍过 Vuepress 的一款全文搜索插件 fulltext-search,今天来介绍另一款相对不错的全文搜索插件 vuepress-plugin-flexsearch-pro。

# 介绍

插件原项目:vuepress-plugin-flexsearch (opens new window)

这款插件最大的问题就是不支持中文,且是比较早创建的仓库,而且作者最后一次提交是在 21 年,因此基本不维护了。

有人基于这个插件改进了支持中文、英文、德文、韩文、日文的全文搜索的插件:vuepress-plugin-flexsearch-pro (opens new window)

# 效果

先来看下插件安装之后的使用效果:

# 安装

可通过如下命令进行安装:

yarn add -D vuepress-plugin-flexsearch-pro

1

# 配置

精简配置,这就够用了。

// .vuepress/config.js

module.exports = {
  plugins: [
    ["flexsearch-pro"],
    // other plugins
  ],
};

1
2
3
4
5
6
7
8

更丰富的配置项:

// .vuepress/config.js

module.exports = {
  plugins: [
    [
      "flexsearch-pro",
      {
        /*
          自定义搜索参数
        */
        searchPaths: ["path1", "path2"], // 搜索路径数组,为空表示搜索全部路径
        searchHotkeys: ["s"], // 激活搜索控件的热键, 默认是 "s" ,也可以添加更多热键
        searchResultLength: 60, // 搜索结果展示的字符长度, 默认是60个字节
      },
    ],
    // other plugins
  ],
};

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 最后

目前已经介绍了两种比较理想的全文搜索插件,但最终我都没有采用,一个最主要的原因就是启用全文搜索插件之后,打包后的 app.xxx.js 文件膨胀了太多。

实测结果如下同等,在同等内容之下,文件大小对比如下:

  • 不启用全文搜索:2.9M。
  • 启用 vuepress-plugin-flexsearch-pro 插件:7M。
  • 启用 fulltext-search 插件:13M。

而这个 js 文件又是全局样式加载时都会依赖的一个文件,如果文件体积过大,则对于博客整体的访问速度都会有很大的影响,因此这是我放弃使用这两个插件的原因。