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

@aixdb/utils

v1.0.1

Published

A TypeScript library for generating and managing JSON-LD data

Readme

@aixdb/utils

一个用于生成和管理 JSON-LD 数据的 TypeScript 工具库。该库提供了简单易用的 API 来生成符合 Schema.org 规范的 JSON-LD 数据,支持网站基本信息、组织信息、产品列表、面包屑导航等多种结构化数据。

特性

  • 🚀 完全使用 TypeScript 编写,提供完整的类型定义
  • 📦 支持多种模块格式(CommonJS、ES Module、UMD)
  • 🎯 符合 Schema.org 规范
  • 🔧 支持自定义配置和扩展
  • 📝 详细的代码注释和文档

安装

使用 npm:

npm install @aixdb/utils

使用 yarn:

yarn add @aixdb/utils

使用 pnpm:

pnpm add @aixdb/utils

使用方法

基础配置

import { getConfig, generateJsonLd } from '@aixdb/utils';

// 基础配置数据
const configData = {
  siteUrl: 'https://example.com',
  title: '网站标题',
  description: '网站描述',
  keywords: '关键词1,关键词2',
  menu: [
    {
      ID: '1',
      name_ch: '首页',
      path: '/',
      type: 'home',
      children: []
    }
  ],
  products: [],
  knowledge: [],
  news: [],
  companyName: '公司名称',
  brandName: '品牌名称',
  address: '公司地址',
  phoneNumber: '1234567890',
  email: '[email protected]'
  logourl: 'https://example.com/logo.png'
};

// 生成 JSON-LD 配置
const jsonLdConfig = getConfig(configData);

// 生成特定页面的 JSON-LD 数据
const pageJsonLd = generateJsonLd(jsonLdConfig, '/products/detail/123');

支持的 JSON-LD 类型

  • WebPage
  • Organization
  • Product
  • BreadcrumbList
  • ItemList

API 文档

getConfig(configData: ConfigData): JsonLdConfig

生成完整的 JSON-LD 配置。

参数:

  • configData: 配置数据对象,包含网站基本信息、菜单结构、产品列表等

返回:

  • JsonLdConfig: JSON-LD 配置对象

generateJsonLd(config: JsonLdConfig, path: string): Record<string, unknown>

生成特定页面的 JSON-LD 数据。

参数:

  • config: JSON-LD 配置对象
  • path: 当前页面路径

返回:

  • Record<string, unknown>: 生成的 JSON-LD 数据对象

开发

# 安装依赖
pnpm install

# 开发模式
pnpm dev

# 构建
pnpm build

# 代码检查
pnpm lint

# 代码格式化
pnpm format

类型定义

interface ConfigData {
  siteUrl: string;
  title: string;
  description: string;
  keywords: string;
  menu: MenuNode[];
  products: any[];
  knowledge: any[];
  news: any[];
  companyName: string;
  brandName: string;
  address: string;
  phoneNumber: string;
  email: string;
  logourl: string;
};

interface MenuNode {
  ID: string;
  name_ch: string;
  path: string;
  type: string;
  children?: MenuNode[];
}