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

@23blocks/block-content

v3.3.0

Published

Content block for the 23blocks SDK - blog posts, comments, categories, and tags.

Readme

@23blocks/block-content

Content block for the 23blocks SDK - blog posts, comments, categories, and tags.

npm version License: MIT

Installation

npm install @23blocks/block-content @23blocks/transport-http

Overview

This package provides content management functionality including:

  • Posts - Blog posts and articles
  • Comments - User comments on posts
  • Categories - Content categorization
  • Tags - Content tagging

Quick Start

import { createHttpTransport } from '@23blocks/transport-http';
import { createContentBlock } from '@23blocks/block-content';

const transport = createHttpTransport({
  baseUrl: 'https://api.yourapp.com',
  headers: () => {
    const token = localStorage.getItem('access_token');
    return token ? { Authorization: `Bearer ${token}` } : {};
  },
});

const content = createContentBlock(transport, {
  apiKey: 'your-api-key',
});

// List published posts
const { data: posts } = await content.posts.list({
  status: 'published',
  limit: 10,
});

posts.forEach((post) => {
  console.log(post.title, post.publishedAt);
});

Services

posts - Post Management

// List posts
const { data: posts, meta } = await content.posts.list({
  limit: 20,
  categoryId: 'category-id',
  status: 'published',
});

// Get post by ID
const post = await content.posts.get('post-id');

// Get post by slug
const post = await content.posts.getBySlug('my-post-slug');

// Create post
const newPost = await content.posts.create({
  title: 'My New Post',
  content: 'Post content here...',
  excerpt: 'Short summary',
  slug: 'my-new-post',
  categoryId: 'category-id',
  tagIds: ['tag-1', 'tag-2'],
  status: 'draft',
});

// Update post
const updated = await content.posts.update('post-id', {
  title: 'Updated Title',
  status: 'published',
  publishedAt: new Date().toISOString(),
});

// Delete post
await content.posts.delete('post-id');

comments - Comment Management

// List comments for a post
const { data: comments } = await content.comments.list({
  postId: 'post-id',
  status: 'approved',
});

// Get comment by ID
const comment = await content.comments.get('comment-id');

// Create comment
const newComment = await content.comments.create({
  postId: 'post-id',
  content: 'Great article!',
  authorName: 'John Doe',
  authorEmail: '[email protected]',
});

// Update comment
const updated = await content.comments.update('comment-id', {
  status: 'approved',
});

// Delete comment
await content.comments.delete('comment-id');

categories - Category Management

// List categories
const { data: categories } = await content.categories.list();

// Get category by ID
const category = await content.categories.get('category-id');

// Create category
const newCategory = await content.categories.create({
  name: 'Technology',
  slug: 'technology',
  description: 'Technology related posts',
  parentId: null,
});

// Update category
const updated = await content.categories.update('category-id', {
  description: 'Updated description',
});

// Delete category
await content.categories.delete('category-id');

tags - Tag Management

// List tags
const { data: tags } = await content.tags.list();

// Get tag by ID
const tag = await content.tags.get('tag-id');

// Create tag
const newTag = await content.tags.create({
  name: 'JavaScript',
  slug: 'javascript',
});

// Update tag
const updated = await content.tags.update('tag-id', {
  name: 'TypeScript',
  slug: 'typescript',
});

// Delete tag
await content.tags.delete('tag-id');

Types

import type {
  Post,
  Comment,
  Category,
  Tag,
  CreatePostRequest,
  UpdatePostRequest,
  CreateCommentRequest,
  CreateCategoryRequest,
  CreateTagRequest,
  ListPostsParams,
} from '@23blocks/block-content';

Post

| Property | Type | Description | |----------|------|-------------| | id | string | Post ID | | uniqueId | string | Unique identifier | | title | string | Post title | | content | string | Post content (HTML/markdown) | | excerpt | string | Short summary | | slug | string | URL-friendly slug | | status | string | draft, published, archived | | categoryId | string | Category ID | | authorId | string | Author user ID | | publishedAt | Date | Publication date | | tags | Tag[] | Associated tags |

Comment

| Property | Type | Description | |----------|------|-------------| | id | string | Comment ID | | postId | string | Parent post ID | | content | string | Comment content | | authorName | string | Author name | | authorEmail | string | Author email | | status | string | pending, approved, spam | | parentId | string | Parent comment ID (for replies) |

Error Handling

import { isBlockErrorException, ErrorCodes } from '@23blocks/contracts';

try {
  await content.posts.get('invalid-id');
} catch (error) {
  if (isBlockErrorException(error)) {
    switch (error.code) {
      case ErrorCodes.NOT_FOUND:
        console.log('Post not found');
        break;
      case ErrorCodes.UNAUTHORIZED:
        console.log('Not authorized to view this post');
        break;
    }
  }
}

Related Packages

License

MIT - Copyright (c) 2024 23blocks