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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vitepress-next-prev-nav

v0.1.2

Published

A VitePress plugin to automatically generate prev/next navigation links from custom article lists, featuring a gennav CLI and custom UI component.

Readme

vitepress-next-prev-nav

Plugin tự động tạo và hiển thị thanh điều hướng Bài trước / Bài tiếp theo (Prev / Next) cho các trang tài liệu trong VitePress dựa trên danh sách bài viết bạn cung cấp.

Đặc điểm nổi bật:

  • Không cần tạo Theme/Layout custom: Tự động tương thích 100% với giao diện mặc định (Default Theme) của VitePress thông qua frontmatter.prevfrontmatter.next.
  • Hỗ trợ CLI gennav: Tự động quét thư mục .md và tạo file danh sách điều hướng.
  • Hỗ trợ nhiều danh sách nav: Dễ dàng phân chia nav cho từng mục/chủ đề khác nhau.

📦 Cài đặt

npm install vitepress-next-prev-nav
# hoặc
yarn add vitepress-next-prev-nav
# hoặc
pnpm add vitepress-next-prev-nav

🚀 Cách sử dụng (Chỉ 1 bước duy nhất)

Chỉ cần cấu hình trong file .vitepress/config.ts bằng cách sử dụng defineConfigFilelistNav từ package:

// .vitepress/config.ts
import { defineConfig, FilelistNav } from 'vitepress-next-prev-nav'

// Danh sách các bài viết theo đúng thứ tự đọc
const myList = [
  { text: 'Mục lục', link: '/guide/mucluc' },
  { text: 'Bài 1: Giới thiệu', link: '/guide/bai-1' },
  { text: 'Bài 2: Cài đặt', link: '/guide/bai-2' },
]

export default defineConfig({
  // ... Các cấu hình VitePress khác của bạn
  plugins: [
    FilelistNav(myList)
  ]
})

🎉 Xong! VitePress sẽ tự động hiển thị nút chuyển bài ở cuối mỗi trang tài liệu có trong danh sách.


🛠 Tự động tạo danh sách bài viết bằng CLI gennav

Thay vì tự gõ danh sách bằng tay, bạn có thể dùng CLI gennav để quét tự động các file .md trong thư mục:

# Quét thư mục docs/feyman/ và tự động tạo file nav.json trong thư mục đó (docs/feyman/nav.json)
npx gennav docs/feyman/

# Tương tự cho thư mục khác:
npx gennav docs/math/

Sau đó import các file nav.json vào .vitepress/config.ts:

// .vitepress/config.ts
import { defineConfig, FilelistNav } from 'vitepress-next-prev-nav'
import feymanNav from '../docs/feyman/nav.json'
import mathNav from '../docs/math/nav.json'

export default defineConfig({
  plugins: [
    // Truyền nhiều nav dạng tham số riêng biệt:
    FilelistNav(feymanNav, mathNav)
    
    // ...hoặc truyền dạng mảng: FilelistNav([feymanNav, mathNav])
  ]
})

🎨 Tùy chọn: Sử dụng UI Component custom (<NextPrevNav />)

Mặc định, plugin tự động kích hoạt giao diện Next/Prev sẵn có của VitePress. Nếu bạn muốn tự tùy chỉnh giao diện UI điều hướng riêng, package có cung cấp sẵn component <NextPrevNav />:

  1. Đăng ký component trong .vitepress/theme/index.js:

    import DefaultTheme from 'vitepress/theme'
    import { registerNextPrevNav } from 'vitepress-next-prev-nav/theme'
    
    export default {
      extends: DefaultTheme,
      enhanceApp({ app }) {
        registerNextPrevNav(app)
      }
    }
  2. Dùng thẻ <NextPrevNav /> trong file Vue Layout hoặc template của bạn.


💡 Cách hoạt động

Plugin FilelistNav chạy trong quá trình VitePress build/dev. Nó tự động tính toán bài trước (prev) và bài sau (next) dựa trên thứ tự trong danh sách, sau đó inject vào frontmatter (pageData.frontmatter.prev & pageData.frontmatter.next) của từng trang .md.

Do đó, VitePress Default Theme nhận diện được dữ liệu này và tự động hiển thị thanh điều hướng ở cuối bài viết.


🛠 Phát triển Package (Local Development)

# Cài đặt dependencies
npm install

# Build TypeScript & CLI bằng tsup
npm run build

# Thử nghiệm local với project VitePress khác
npm link
# Ở project VitePress test:
npm link vitepress-next-prev-nav

Cấu trúc dự án

vitepress-next-prev-nav/
├── bin/
│   └── gennav.ts           # CLI entry point
├── src/
│   ├── index.ts            # Entry point chính (export FilelistNav, defineConfig)
│   ├── core/
│   │   └── filelist-nav.ts # Logic tính toán & gán frontmatter prev/next
│   ├── cli/
│   │   └── generate.ts     # Logic quét markdown files của gennav
│   └── theme/              # Vue Component tùy chọn nếu muốn custom UI
│       ├── index.js        # registerNextPrevNav(app)
│       ├── NextPrevNav.vue # Component UI custom
│       └── useNextPrevNav.js