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

@10up/block-renderer-preferences

v0.1.7

Published

User preferences and style guide configuration for WordPress block generation

Readme

@10up/block-renderer-preferences

Load and manage user preferences for AI block generation. Preferences guide AI assistants on preferred blocks, styles, and patterns.

Installation

npm install @10up/block-renderer-preferences
# or
pnpm add @10up/block-renderer-preferences

Overview

This package:

  1. Loads preferences - From block-preferences.json or .blockrc.json
  2. Validates with Zod - Ensures preference files are correctly formatted
  3. Formats for AI prompts - Converts preferences to AI-friendly text
  4. Provides defaults - Sensible defaults when no file exists

Usage

Load Preferences

Automatically find and load preferences from a directory:

import { loadPreferences } from '@10up/block-renderer-preferences';

const prefs = loadPreferences('/path/to/project');
// Searches for:
// - /path/to/project/block-preferences.json
// - /path/to/project/.blockrc.json
// - /path/to/project/.block-renderer/preferences.json

if (prefs) {
  console.log(prefs.preferredBlocks);
  console.log(prefs.avoidBlocks);
  console.log(prefs.styleGuide);
}

Load from Specific File

import { loadPreferencesFromFile } from '@10up/block-renderer-preferences';

const prefs = loadPreferencesFromFile('/path/to/custom-prefs.json');

Find Preferences File

import { findPreferencesFile } from '@10up/block-renderer-preferences';

const filePath = findPreferencesFile('/path/to/project');
// Returns path to preferences file or null if not found

Create Default Preferences

import { createDefaultPreferences } from '@10up/block-renderer-preferences';

const defaults = createDefaultPreferences();
// Returns sensible default configuration

Merge Preferences

Combine multiple preference sources:

import { mergePreferences, createDefaultPreferences } from '@10up/block-renderer-preferences';

const defaults = createDefaultPreferences();
const userPrefs = loadPreferencesFromFile('/path/to/prefs.json');
const merged = mergePreferences(defaults, userPrefs);

Format for AI Prompts

import { formatPreferencesForPrompt } from '@10up/block-renderer-preferences';

const promptSection = formatPreferencesForPrompt(prefs);
// Returns formatted markdown for AI system prompt

Preferences Schema

BlockPreferencesConfig

The main configuration object:

interface BlockPreferencesConfig {
  // Block preferences
  blocks?: BlocksPreferences;

  // Layout preferences
  layout?: LayoutPreferences;

  // Typography preferences
  typography?: TypographyPreferences;

  // Color preferences
  colors?: ColorPreferences;

  // Spacing preferences
  spacing?: SpacingPreferences;

  // Image preferences
  images?: ImagePreferences;

  // Style guide
  styleGuide?: StyleGuide;

  // Brand guidelines
  brand?: BrandGuideline;
}

BlocksPreferences

interface BlocksPreferences {
  /** Blocks to prefer when multiple options exist */
  preferred?: string[];
  /** Blocks to avoid using */
  avoid?: string[];
  /** Default block for text content */
  defaultText?: string;
  /** Default container block */
  defaultContainer?: string;
}

LayoutPreferences

interface LayoutPreferences {
  /** Default layout type for groups */
  defaultType?: 'constrained' | 'flex' | 'flow' | 'grid';
  /** Maximum content width */
  maxWidth?: string;
  /** Default alignment */
  defaultAlign?: 'left' | 'center' | 'right' | 'wide' | 'full';
}

TypographyPreferences

interface TypographyPreferences {
  /** Use semantic heading levels */
  useSemanticHeadings?: boolean;
  /** Maximum heading level to use */
  maxHeadingLevel?: 1 | 2 | 3 | 4 | 5 | 6;
  /** Default font size */
  defaultFontSize?: string;
}

ColorPreferences

interface ColorPreferences {
  /** Preferred color tokens to use */
  preferred?: string[];
  /** Colors to avoid */
  avoid?: string[];
  /** Default background color */
  defaultBackground?: string;
  /** Default text color */
  defaultText?: string;
}

SpacingPreferences

interface SpacingPreferences {
  /** Default spacing token */
  default?: string;
  /** Preferred spacing scale */
  scale?: string[];
}

ImagePreferences

interface ImagePreferences {
  /** Preferred image sizes */
  preferredSizes?: string[];
  /** Default aspect ratio */
  defaultAspectRatio?: string;
  /** Always include alt text */
  requireAlt?: boolean;
}

StyleGuide

interface StyleGuide {
  /** Custom style rules */
  rules?: string[];
  /** Preferred patterns by category */
  patternsByCategory?: Record<string, string[]>;
  /** Patterns to avoid */
  avoidPatterns?: string[];
}

BrandGuideline

interface BrandGuideline {
  /** Brand name */
  name?: string;
  /** Brand description */
  description?: string;
  /** Voice and tone guidelines */
  voiceTone?: string[];
}

Example Configuration

{
  "blocks": {
    "preferred": ["core/group", "core/columns"],
    "avoid": ["core/freeform", "core/html"],
    "defaultText": "core/paragraph",
    "defaultContainer": "core/group"
  },
  "layout": {
    "defaultType": "constrained",
    "defaultAlign": "wide"
  },
  "typography": {
    "useSemanticHeadings": true,
    "maxHeadingLevel": 4
  },
  "colors": {
    "preferred": ["primary", "secondary", "base", "contrast"],
    "avoid": ["error", "warning"]
  },
  "spacing": {
    "default": "50",
    "scale": ["30", "40", "50", "60", "70"]
  },
  "images": {
    "preferredSizes": ["large", "full"],
    "requireAlt": true
  },
  "styleGuide": {
    "rules": [
      "Always use constrained layout for content groups",
      "Prefer flex layout for button containers",
      "Use consistent spacing throughout sections"
    ],
    "patternsByCategory": {
      "hero": ["theme/hero-centered", "theme/hero-split"]
    },
    "avoidPatterns": ["theme/deprecated-banner"]
  },
  "brand": {
    "name": "Acme Corp",
    "voiceTone": [
      "Professional but approachable",
      "Clear and concise",
      "Helpful and supportive"
    ]
  }
}

Complete Exports

Functions

| Function | Description | |----------|-------------| | loadPreferences(directory) | Auto-detect and load preferences | | loadPreferencesFromFile(filePath) | Load from specific file | | findPreferencesFile(directory) | Find preferences file path | | createDefaultPreferences() | Create default configuration | | mergePreferences(base, override) | Merge preference objects | | formatPreferencesForPrompt(prefs) | Format for AI prompt |

Types

| Type | Description | |------|-------------| | BlockPreferencesConfig | Main configuration type | | BlocksPreferences | Block selection preferences | | LayoutPreferences | Layout preferences | | TypographyPreferences | Typography preferences | | ColorPreferences | Color preferences | | SpacingPreferences | Spacing preferences | | ImagePreferences | Image preferences | | StyleGuide | Style guide rules | | BrandGuideline | Brand guidelines | | Preferences | Alias for BlockPreferencesConfig |

Zod Schemas

| Schema | Description | |--------|-------------| | blockPreferencesConfigSchema | Main config schema | | blockPreferencesSchema | Block preferences schema | | layoutPreferencesSchema | Layout preferences schema | | typographyPreferencesSchema | Typography preferences schema | | colorPreferencesSchema | Color preferences schema | | spacingPreferencesSchema | Spacing preferences schema | | imagePreferencesSchema | Image preferences schema | | styleGuideSchema | Style guide schema | | brandGuidelineSchema | Brand guideline schema | | preferencesSchema | Alias for main schema |

License

MIT