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

@kitmodule/kitsubstack

v1.0.2

Published

Fetch Substack posts, convert to Markdown with front matter, replace content, and export as ZIP — lightweight, dependency-free, and easy to use.

Readme

📝 KitSubStack by Kitmodule

Lấy bài viết từ Substack, chuyển sang Markdown kèm front matter, thay thế nội dung, và xuất ra ZIP — nhẹ, không phụ thuộc, dễ sử dụng.

English | Tiếng Việt

npm version license


✨ Tính năng

  • 📬 Lấy bài viết từ bất kỳ người dùng Substack nào.
  • 🏷️ Tạo Markdown kèm front matter cho Hashnode, Hugo, Jekyll, Astro, hoặc định dạng tùy chỉnh.
  • 🔄 Thay thế nhiều chuỗi trong nội dung Markdown (replaces giống Golang strings.NewReplacer).
  • ⚡ Hỗ trợ lấy bài viết tuần tự hoặc đồng thời với giới hạn tùy chọn.
  • 💨 API chainable: offset, limit, đánh số file, callback tiến trình, callback hoàn thành.
  • 📦 Xuất nhiều bài viết ra file ZIP tự động.

🚀 Cài đặt

Sử dụng npm

npm install @kitmodule/kitsubstack

Sử dụng CDN

<script src="https://unpkg.com/@kitmodule/kitsubstack/dist/kitsubstack.min.js"></script>

hoặc

<script src="https://cdn.jsdelivr.net/npm/kitsubstack/dist/kitsubstack.min.js"></script>

💡 Cách dùng

Trình duyệt (CDN)

<script src="https://unpkg.com/@kitmodule/kitsubstack-js/dist/kitsubstack.min.js"></script>
<script>
  const kit = new KitSubStack("example.substack.com");

  kit.offset(0)
     .limit(5)
     .numbering(true)
     .frontMatter("hashnode")
     .replaces("Substack", "Hashnode")
     .progress(fetch => {
         if (fetch.success) console.log("✅ Đã lấy:", fetch.post.slug);
         else console.error("❌ Lỗi:", fetch.slug ?? "unknown");
     })
     .completed(filename => console.log("✅ ZIP sẵn sàng:", filename))
     .zip();
</script>

Node.js / CommonJS

const { KitSubStack, zipSubstackToHashnode } = require("kitsubstack-js");

// Sử dụng cơ bản
const kit = new KitSubStack("example.substack.com");

await kit.offset(0)
         .limit(10)
         .frontMatter("hashnode")
         .zip();

// Shortcut helper
await zipSubstackToHashnode("example.substack.com", 0, 5, true);

🧩 Tham khảo API

new KitSubStack(input)

| Tham số | Loại | Mô tả | | ------- | --------------- | ------------------------------------ | | input | string | object | Username, hostname hoặc URL Substack |

Các phương thức chainable

| Phương thức | Mô tả | | | ---------------------- | ----------------------------------------------------------------------- | ------------------------------------------------ | | .offset(n) | Bắt đầu từ bài viết thứ n | | | .limit(n) | Lấy tối đa n bài viết | | | .numbering(true | false) | Thêm số thứ tự vào tên file | | .progress(callback) | Callback khi mỗi bài được lấy | | | .completed(callback) | Callback khi ZIP đã tạo xong | | | .concurrent(n) | Lấy nhiều bài cùng lúc, tối đa n | | | .replaces(...args) | Thay thế nhiều chuỗi trong nội dung, ví dụ .replaces("0","1","2","3") | | | .frontMatter(type | callback) | Chọn preset front matter hoặc function tùy chỉnh | | .zip() | Lấy bài, tạo Markdown + front matter, và xuất ZIP | |


Preset Front Matter

| Preset | Trường dữ liệu | | -------- | --------------------------------------------------------- | | hashnode | title, slug, tags, date, image | | hugo | title, slug, date, draft, tags, description, cover | | jekyll | layout, title, slug, date, categories, description, image | | astro | title, pubDate, description, tags, heroImage | | default | title, slug, date, description, image |

Hỗ trợ async custom function:

kit.frontMatter(async post => ({
    title: post.title.toUpperCase(),
    date: post.post_date,
    tags: post.postTags?.map(t => t.name) ?? [],
}));

Thay thế nhiều chuỗi

kit.replaces(
    "Substack", "Hashnode",
    "2025", "2026"
);
  • Hoạt động giống strings.NewReplacer trong Golang.
  • Thay thế tất cả các xuất hiện trong nội dung bài viết.

📦 Các gói đã tích hợp / gợi ý sử dụng

KitSubStack là không phụ thuộc vào thư viện ngoài và đã tích hợp sẵn các gói Kit sau:

| Gói | Mục đích | Tích hợp trong KitSubStack? | | ------------------------------------------------------------- | ------------------------------------------------------------------- | --------------------------- | | KitZip JS | Tạo file ZIP từ Markdown hoặc các tệp khác; nhẹ, chuỗi (chainable). | ✅ Đã tích hợp sẵn | | KitYAML JS | Chuyển đổi JavaScript object thành YAML front matter cho Markdown. | ✅ Đã tích hợp sẵn | | KitMarkdown JS | Chuyển HTML sang Markdown, nhẹ và không phụ thuộc thư viện ngoài. | ✅ Đã tích hợp sẵn |

⚡ Lưu ý: Bạn không cần cài thêm gì để sử dụng KitSubStack. Các gói này được tích hợp sẵn và hoạt động trực tiếp. Tuy nhiên, nếu muốn, bạn vẫn có thể sử dụng riêng từng module trong các dự án khác, hoặc tích hợp vào workflow tùy chỉnh như: fetch bài → chuyển HTML sang Markdown → tạo YAML front matter → xuất ZIP.

☕ Ủng hộ tác giả

Nếu bạn thấy thư viện hữu ích, bạn có thể ủng hộ:

Ko-fi Buy Me a Coffee GitHub Sponsors Patreon PayPal


🧾 License

Phát hành theo MIT License © 2025 Huỳnh Nhân Quốc · Open Source @Kit Module