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

@bernierllc/content-type-text

v1.2.0

Published

Bare bones text content type with TipTap WYSIWYG editor and markdown file storage

Readme

@bernierllc/content-type-text

Bare bones text content type with TipTap WYSIWYG editor and markdown file storage.

Installation

npm install @bernierllc/content-type-text

Overview

This package provides a minimal, foundational text content type designed to be extended by specialized content types (blog posts, tweets, commit messages, etc.). It includes:

  • Bare bones TipTap WYSIWYG editor with starter-kit only
  • Markdown file storage with basic frontmatter (content, createdAt, updatedAt)
  • Content type registration with @bernierllc/content-type-registry
  • Simple, extensible API for custom text types

Features

  • ✅ Minimal TipTap editor configuration
  • ✅ Markdown file storage with frontmatter
  • ✅ Content validation with Zod
  • ✅ TypeScript with strict mode
  • ✅ 90%+ test coverage
  • ✅ Zero dependencies (except TipTap, Zod, gray-matter)

Usage

Basic Usage

import { TextContentType, createTextContentType } from '@bernierllc/content-type-text';

// Create instance
const textType = createTextContentType({
  id: 'text',
  name: 'Text',
  storageDirectory: './content',
});

// Create content
const result = await textType.create('Hello, world!');
console.log(result.data); // File path: ./content/1234567890-hello-world.md

// Read content
const readResult = await textType.read(result.data!);
console.log(readResult.data?.content); // "Hello, world!"

// Update content
await textType.update(result.data!, 'Updated content');

// Delete content
await textType.delete(result.data!);

Register with Content Type Registry

import { ContentTypeRegistry } from '@bernierllc/content-type-registry';
import { TextContentType } from '@bernierllc/content-type-text';

const registry = new ContentTypeRegistry();
const textType = new TextContentType();

await textType.register(registry);

Using TipTap Editor

import { createTipTapEditor, getMarkdownFromEditor, destroyEditor } from '@bernierllc/content-type-text';

// Create editor (requires DOM environment)
const editor = createTipTapEditor({
  content: 'Initial content',
  editable: true,
});

// Get content
const markdown = getMarkdownFromEditor(editor);

// Clean up
destroyEditor(editor);

Extending for Custom Types

import { TextContentType } from '@bernierllc/content-type-text';

class BlogPostType extends TextContentType {
  constructor() {
    super({
      id: 'blog-post',
      name: 'Blog Post',
      storageDirectory: './blog-posts',
    });
  }

  // Add custom methods
  async addMetadata(filePath: string, metadata: any) {
    // Custom implementation
  }
}

API

TextContentType

Main class for text content management.

Constructor

new TextContentType(config?: TextContentTypeConfig)

Config Options:

  • id (string, default: 'text') - Content type identifier
  • name (string, default: 'Text') - Content type display name
  • storageDirectory (string, default: './content') - Storage directory path

Methods

register(registry: ContentTypeRegistry): Promise<TextContentResult<void>>

Register this content type with the registry.

create(content: string): Promise<TextContentResult<string>>

Create new text content. Returns file path on success.

read(filePath: string): Promise<TextContentResult<TextContentMetadata>>

Read text content from file.

update(filePath: string, content: string): Promise<TextContentResult<void>>

Update existing text content.

delete(filePath: string): Promise<TextContentResult<void>>

Delete text content file.

validate(data: unknown): TextContentResult<TextContentMetadata>

Validate text content metadata.

Types

TextContentMetadata

interface TextContentMetadata {
  content: string;
  createdAt: Date;
  updatedAt: Date;
}

TextContentResult

interface TextContentResult<T = unknown> {
  success: boolean;
  data?: T;
  error?: string;
}

TipTapEditorConfig

interface TipTapEditorConfig {
  content?: string;
  editable?: boolean;
}

Storage Format

Content is stored as markdown files with YAML frontmatter:

---
createdAt: '2025-01-01T00:00:00.000Z'
updatedAt: '2025-01-02T00:00:00.000Z'
---
Your content here...

Filenames are generated as: {timestamp}-{sanitized-content}.md

Examples

Complete CRUD Operations

import { createTextContentType } from '@bernierllc/content-type-text';

const textType = createTextContentType({ storageDirectory: './my-content' });

// Create
const createResult = await textType.create('My first post');
const filePath = createResult.data!;

// Read
const readResult = await textType.read(filePath);
console.log(readResult.data?.content); // "My first post"
console.log(readResult.data?.createdAt); // Date object

// Update
await textType.update(filePath, 'My updated post');

// Read again
const updatedResult = await textType.read(filePath);
console.log(updatedResult.data?.content); // "My updated post"

// Delete
await textType.delete(filePath);

Error Handling

const result = await textType.read('/non/existent/file.md');

if (!result.success) {
  console.error('Error:', result.error);
} else {
  console.log('Content:', result.data?.content);
}

Validation

const validationResult = textType.validate({
  content: 'Valid content',
  createdAt: new Date(),
  updatedAt: new Date(),
});

if (validationResult.success) {
  console.log('Valid:', validationResult.data);
} else {
  console.error('Invalid:', validationResult.error);
}

Integration Status

  • Logger: not-applicable - Base content type has no side effects requiring logging
  • Docs-Suite: ready - TypeScript types and documentation exported
  • NeverHub: not-applicable - Core type definition with no service mesh participation

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Build package
npm run build

# Lint code
npm run lint

License

Copyright (c) 2025 Bernier LLC

This file is licensed to the client under a limited-use license. The client may use and modify this code only within the scope of the project it was delivered for. Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.

Related Packages

Integration Status

Logger Integration

  • Status: not-applicable
  • Justification: Core content type package with standard error handling. File operations use try/catch patterns.

NeverHub Integration

  • Status: not-applicable
  • Justification: Core package providing content type definition. Services and suites that USE this package will handle NeverHub integration for content management events.

Docs-Suite Compatibility

  • Status: ready
  • Format: typedoc
  • Documentation: Complete API documentation with TypeScript types