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

@resonia/sanity-plugin-trenddraft

v0.2.0

Published

TrendDraft AI content generation for Sanity Studio

Readme

@resonia/sanity-plugin-trenddraft

AI content generation for Sanity Studio powered by TrendDraft

Status: ✅ Published to npm (v0.1.0)

Generate AI-powered content directly in Sanity Studio with your unique voice and style. TrendDraft learns your writing patterns and incorporates your opinions into generated content.

Features

  • AI Content Generation - Generate content from titles/topics directly in text fields
  • Style Profiles - Use your TrendDraft style profiles for consistent voice
  • Opinion Alignment - AI incorporates your recorded opinions and perspectives
  • Content Goals - Specify goals (Educate, Convert, Engage, etc.)
  • Field-Level Generation - Works on text, string, and rich text fields

Installation

npm install @resonia/sanity-plugin-trenddraft
# or
pnpm add @resonia/sanity-plugin-trenddraft
# or
yarn add @resonia/sanity-plugin-trenddraft

Configuration

Add it as a plugin in your sanity.config.ts:

import { defineConfig } from 'sanity';
import { trenddraft } from '@resonia/sanity-plugin-trenddraft';

export default defineConfig({
  // ... other config
  plugins: [
    trenddraft({
      apiKey: process.env.SANITY_STUDIO_TRENDDRAFT_API_KEY!,
      defaultStyleProfile: 'company-voice', // optional
      enableOpinionAlignment: true, // optional, default: true
      fields: ['body', 'excerpt', 'metaDescription'], // optional
      defaultWordCount: 800, // optional, default: 800
    }),
  ],
});

Environment Variables

Create a .env file in your Sanity studio:

SANITY_STUDIO_TRENDDRAFT_API_KEY=your_api_key_here

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | Required | Your TrendDraft API key | | defaultStyleProfile | string | - | Default style profile ID | | enableOpinionAlignment | boolean | true | Include opinions in generation | | fields | string[] | ['body', 'content', 'excerpt', 'description'] | Fields to enable TrendDraft on | | defaultWordCount | number | 800 | Default target word count | | apiUrl | string | - | Custom API URL (for testing) |

Usage

Once configured, TrendDraft adds a "Generate with TrendDraft" button below enabled text fields:

  1. Click "Generate with TrendDraft" on any enabled field
  2. Enter a title/topic for your content
  3. Select a style profile (optional)
  4. Add keywords (optional)
  5. Choose content goals (optional)
  6. Set target word count
  7. Click "Generate"

The generated content will be inserted into the field.

Getting an API Key

  1. Sign up at trenddraft.xyz
  2. Go to SettingsAPI Keys
  3. Click "Create API Key"
  4. Name it "Sanity Studio"
  5. Select scopes:
    • content:generate (required)
    • profiles:read (required)
    • opinions:read (optional)
  6. Copy the key (shown only once)

Advanced Usage

Custom Input Component

For more control, you can use the input component directly:

import { createTrendDraftInput } from '@resonia/sanity-plugin-trenddraft';

const CustomTrendDraftInput = createTrendDraftInput({
  apiKey: process.env.SANITY_STUDIO_TRENDDRAFT_API_KEY!,
  defaultWordCount: 1200,
});

Using Hooks

Build custom integrations with the provided hooks:

import { useTrendDraftApi, useStyleProfiles } from '@resonia/sanity-plugin-trenddraft';

function MyComponent() {
  const { api, generateContent, isGenerating, error } = useTrendDraftApi({
    apiKey: process.env.SANITY_STUDIO_TRENDDRAFT_API_KEY!,
  });

  const { profiles, selectedProfile, selectProfile } = useStyleProfiles({
    api,
  });

  // ... your custom implementation
}

Direct API Access

import { createApiClient } from '@resonia/sanity-plugin-trenddraft';

const api = createApiClient(process.env.SANITY_STUDIO_TRENDDRAFT_API_KEY!);

// Get profiles
const profiles = await api.getStyleProfiles();

// Generate content
const content = await api.generateContent({
  title: 'My Article Title',
  styleProfileId: 'profile-id',
  targetWordCount: 1000,
});

Supported Field Types

TrendDraft automatically enables on these field types (when field name matches):

Simple Text Fields:

  • string
  • text

Rich Text / Portable Text Fields:

  • array of block (e.g., blockContent, body)
  • Any Portable Text field

Default Field Names:

  • body
  • content
  • excerpt
  • description
  • text
  • blockContent

Customize with the fields configuration option.

Portable Text Support

For Portable Text (block content) fields, TrendDraft will:

  • Convert generated text to Portable Text block format
  • Support Markdown-style headings (## H2, ### H3, #### H4)
  • Support blockquotes (> quote)
  • Allow appending to existing content or replacing it

Example schema that works with TrendDraft:

defineField({
  name: 'body',
  title: 'Body',
  type: 'array',
  of: [
    { type: 'block' },
    { type: 'image' },
    { type: 'code' },
  ],
})

Requirements

  • Sanity Studio v3.0.0+
  • React 18+
  • TrendDraft account with API key

Support

License

MIT © Resonia Inc