npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@qingshu/vitepress-plugin-search

v1.0.3

Published

为vitepress提供离线搜索能力

Downloads

35

Readme

@pzy915/vitepress-plugin-search

vitepress-plugin-search是一个实现vitepress文章离线搜索的插件. 此项目基于 vitepress-plugin-search: 1.0.4-alpha.19 修改而来.

解决的问题/增加的特性:

  1. 解决当 vitepress(版本:1.0.0-alpha.35) 存在 base 设置时, 搜索结果的跳转连接包含两个base值问题
  2. 让索引文档的文档内容包含md文件名(不含.md后缀)(index.md这种文件名除外)。因为本人文章的h1使用的是vitepress变量{{$frontmatter.title}}实际值就是文件名, 插件默认的索引内容并未存储文件名,导致输入文件名进行搜索,无法搜索到内容

解决中文搜索问题

方式一: tokenize 设置为full

pnpm i @pzy915/vitepress-plugin-search -D
import { ConfigEnv, defineConfig } from 'vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { SearchPlugin } from '@pzy915/vitepress-plugin-search'

export default defineConfig((env: ConfigEnv) => {
  return {
    plugins: [
      vueJsx(),
      SearchPlugin({
        previewLength: 20,
        buttonLabel: '搜索',
        placeholder: '文章搜索',
        tokenize: 'full',
      }),
    ],
    server: {
      fs: {
        // Allow serving files from one level up to the project root
        allow: ['../..'],
      },
      host: '0.0.0.0',
      // open: true,
    },
  }
})

方式二: 使用结巴分词器(好像没起作用)

pnpm i @node-rs/jieba @pzy915/vitepress-plugin-search -D

vite.config.ts

import { ConfigEnv, defineConfig } from 'vite'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { SearchPlugin } from '@pzy915/vitepress-plugin-search'
import { load, cut } from '@node-rs/jieba'

export default defineConfig((env: ConfigEnv) => {
  return {
    plugins: [
      vueJsx(),
      /**
       * flexsearch 配置: https://github.com/nextapps-de/flexsearch#options
       *
       * vitepress-plugin-simple-search 配置: https://github.com/stuyk/vitepress-plugin-simple-search
       *
       * @return  {[type]}  [return description]
       */
      SearchPlugin({
        previewLength: 20,
        buttonLabel: '搜索',
        placeholder: '文章搜索',
        /**
         * 采用分词器优化.
         *
         * 中文分词器:https://www.npmjs.com/package/@node-rs/jieba
         *
         * 字典配置:https://www.npmjs.com/package/nodejieba
         *
         * 相关文章: https://zhuanlan.zhihu.com/p/453803476
         */
        tokenize: function (str) {
          return cut(str, false)
        },
      }),
    ],
    server: {
      fs: {
        // Allow serving files from one level up to the project root
        allow: ['../..'],
      },
      host: '0.0.0.0',
      // open: true,
    },
  }
})

Provides local search to your documentation site

Uses flexsearch.

Installing

npm i vitepress-plugin-search markdown-it flexsearch -D

Add the plugin

//vite.config.ts
import { SearchPlugin } from "vitepress-plugin-search";
import { defineConfig } from "vite";

//default options
var options = {
  ...flexSearchIndexOptions,
  previewLength: 62,
  buttonLabel: "Search",
  placeholder: "Search docs",
};

export default defineConfig({
  plugins: [SearchPlugin(options)],
});

Options

Accept FlexSearch Index Options

Multi language support

Provided by flexsearch

See chinese settings for example