CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nuxt--content

File-based content management system for Nuxt.js applications with powerful querying and Vue component rendering in Markdown

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

configuration.mddocs/

Module Configuration

Comprehensive module configuration system with database settings, preview mode, build options, and experimental features for fine-tuning Nuxt Content behavior.

Capabilities

Module Options

Complete configuration interface for the Nuxt Content module.

interface ModuleOptions {
  /** Database configuration and adapter settings */
  database: DatabaseConfig;
  /** Local development database settings */
  _localDatabase?: LocalDevelopmentDatabase;
  /** Preview mode configuration */
  preview?: PreviewOptions;
  /** File watching and HMR configuration */
  watch?: WatchOptions;
  /** Content rendering configuration */
  renderer?: RendererOptions;
  /** Build-time processing options */
  build?: BuildOptions;
  /** Experimental feature flags */
  experimental?: ExperimentalOptions;
}

Usage Examples:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxt/content'],
  
  content: {
    database: {
      type: 'sqlite',
      sqlite: {
        path: '.nuxt/content.db'
      }
    },
    
    preview: {
      enabled: true,
      api: '/api/preview'
    },
    
    watch: {
      enabled: true,
      patterns: ['content/**/*']
    },
    
    renderer: {
      components: {
        'custom-alert': '~/components/Alert.vue'
      }
    },
    
    build: {
      preprocess: true,
      generateTypes: true
    },
    
    experimental: {
      advancedQuery: true,
      serverComponents: false
    }
  }
});

Database Configuration

Database adapter configuration supporting multiple database types.

interface DatabaseConfig {
  /** Database type/adapter */
  type: 'sqlite' | 'd1' | 'postgresql' | 'libsql';
  /** SQLite-specific configuration */
  sqlite?: SqliteDatabaseConfig;
  /** Cloudflare D1 configuration */
  d1?: D1DatabaseConfig;
  /** PostgreSQL configuration */
  postgresql?: PostgreSQLDatabaseConfig;
  /** LibSQL configuration */
  libsql?: LibSQLDatabaseConfig;
}

interface SqliteDatabaseConfig {
  /** Path to SQLite database file */
  path: string;
  /** Enable WAL mode for better concurrency */
  walMode?: boolean;
  /** Connection pool settings */
  pool?: {
    min?: number;
    max?: number;
    acquireTimeout?: number;
  };
}

interface D1DatabaseConfig {
  /** Cloudflare D1 database binding name */
  binding: string;
  /** D1 database ID */
  databaseId: string;
  /** Cloudflare account ID */
  accountId?: string;
  /** API token for D1 operations */
  apiToken?: string;
}

interface PostgreSQLDatabaseConfig {
  /** PostgreSQL connection string */
  connectionString: string;
  /** Connection pool settings */
  pool?: {
    min?: number;
    max?: number;
    acquireTimeout?: number;
    idleTimeout?: number;
  };
  /** SSL configuration */
  ssl?: {
    require?: boolean;
    ca?: string;
    cert?: string;
    key?: string;
  };
}

interface LibSQLDatabaseConfig {
  /** LibSQL database URL */
  url: string;
  /** Authentication token */
  authToken?: string;
  /** Sync URL for embedded replicas */
  syncUrl?: string;
  /** Sync interval in seconds */
  syncInterval?: number;
}

Usage Examples:

// SQLite configuration
const sqliteConfig = {
  database: {
    type: 'sqlite',
    sqlite: {
      path: './data/content.db',
      walMode: true,
      pool: {
        min: 1,
        max: 10,
        acquireTimeout: 30000
      }
    }
  }
};

// Cloudflare D1 configuration
const d1Config = {
  database: {
    type: 'd1',
    d1: {
      binding: 'CONTENT_DB',
      databaseId: 'your-d1-database-id',
      accountId: process.env.CLOUDFLARE_ACCOUNT_ID,
      apiToken: process.env.CLOUDFLARE_API_TOKEN
    }
  }
};

// PostgreSQL configuration
const postgresConfig = {
  database: {
    type: 'postgresql',
    postgresql: {
      connectionString: process.env.DATABASE_URL,
      pool: {
        min: 2,
        max: 20,
        acquireTimeout: 30000,
        idleTimeout: 600000
      },
      ssl: {
        require: true,
        ca: process.env.DB_SSL_CA
      }
    }
  }
};

Preview Options

Configuration for live content editing and preview functionality.

interface PreviewOptions {
  /** Enable preview mode */
  enabled?: boolean;
  /** API endpoint for preview operations */
  api?: string;
  /** Authentication configuration */
  auth?: PreviewAuthConfig;
  /** WebSocket configuration for real-time updates */
  websocket?: WebSocketConfig;
  /** Preview UI customization */
  ui?: PreviewUIConfig;
}

interface PreviewAuthConfig {
  /** Authentication strategy */
  strategy: 'token' | 'session' | 'custom';
  /** Token configuration for token strategy */
  token?: {
    secret: string;
    expiresIn?: string;
    algorithm?: string;
  };
  /** Session configuration for session strategy */
  session?: {
    cookieName?: string;
    maxAge?: number;
    secure?: boolean;
  };
  /** Custom authentication handler */
  handler?: (request: Request) => Promise<boolean>;
}

interface WebSocketConfig {
  /** Enable WebSocket for real-time updates */
  enabled?: boolean;
  /** WebSocket server port */
  port?: number;
  /** WebSocket path */
  path?: string;
}

interface PreviewUIConfig {
  /** Custom CSS for preview UI */
  styles?: string;
  /** Preview toolbar position */
  position?: 'top' | 'bottom' | 'left' | 'right';
  /** Custom preview components */
  components?: Record<string, string>;
}

Watch Options

File watching and hot module replacement configuration.

interface WatchOptions {
  /** Enable file watching */
  enabled?: boolean;
  /** File patterns to watch */
  patterns?: string[];
  /** Directories to ignore */
  ignored?: string[];
  /** Debounce delay in milliseconds */
  debounce?: number;
  /** Watch options for chokidar */
  chokidar?: {
    ignoreInitial?: boolean;
    persistent?: boolean;
    followSymlinks?: boolean;
    depth?: number;
  };
}

Renderer Options

Content rendering and component configuration.

interface RendererOptions {
  /** Custom component mapping for MDC */
  components?: Record<string, string>;
  /** Global component props */
  props?: Record<string, Record<string, unknown>>;
  /** Prose component configuration */
  prose?: ProseConfig;
  /** Markdown processing options */
  markdown?: MarkdownConfig;
  /** Syntax highlighting configuration */
  highlight?: HighlightConfig;
}

interface ProseConfig {
  /** Enable prose components */
  enabled?: boolean;
  /** Prose component prefix */
  prefix?: string;
  /** Custom prose components */
  components?: Record<string, string>;
}

interface MarkdownConfig {
  /** Enable anchor links */
  anchorLinks?: boolean;
  /** Table of contents configuration */
  toc?: {
    depth?: number;
    searchDepth?: number;
  };
  /** Remarkjs plugins */
  remarkPlugins?: Array<string | [string, any]>;
  /** Rehype plugins */
  rehypePlugins?: Array<string | [string, any]>;
}

interface HighlightConfig {
  /** Syntax highlighting theme */
  theme?: string | { light: string; dark: string };
  /** Supported languages */
  langs?: string[];
  /** Enable line numbers */
  lineNumbers?: boolean;
}

Build Options

Build-time processing and optimization configuration.

interface BuildOptions {
  /** Enable content preprocessing */
  preprocess?: boolean;
  /** Generate TypeScript types */
  generateTypes?: boolean;
  /** Minify generated content */
  minify?: boolean;
  /** Content caching strategy */
  cache?: CacheConfig;
  /** Asset optimization */
  assets?: AssetConfig;
}

interface CacheConfig {
  /** Enable content caching */
  enabled?: boolean;
  /** Cache directory */
  dir?: string;
  /** Cache TTL in seconds */
  ttl?: number;
  /** Cache invalidation strategy */
  invalidation?: 'content' | 'time' | 'manual';
}

interface AssetConfig {
  /** Optimize images */
  images?: {
    enabled?: boolean;
    formats?: string[];
    quality?: number;
    sizes?: number[];
  };
  /** Bundle code blocks */
  codeBlocks?: {
    enabled?: boolean;
    bundler?: 'esbuild' | 'rollup';
  };
}

Experimental Options

Feature flags for experimental functionality.

interface ExperimentalOptions {
  /** Advanced query features */
  advancedQuery?: boolean;
  /** Server-side Vue components in content */
  serverComponents?: boolean;
  /** Streaming content delivery */
  streaming?: boolean;
  /** Advanced caching strategies */
  advancedCache?: boolean;
  /** Real-time collaboration */
  collaboration?: boolean;
}

Configuration Examples

Production Configuration

// nuxt.config.ts - Production setup
export default defineNuxtConfig({
  content: {
    database: {
      type: 'postgresql',
      postgresql: {
        connectionString: process.env.DATABASE_URL,
        pool: { min: 5, max: 50 },
        ssl: { require: true }
      }
    },
    
    build: {
      preprocess: true,
      generateTypes: true,
      minify: true,
      cache: {
        enabled: true,
        ttl: 3600,
        invalidation: 'content'
      }
    },
    
    renderer: {
      markdown: {
        anchorLinks: true,
        toc: { depth: 3 }
      },
      highlight: {
        theme: { light: 'github-light', dark: 'github-dark' },
        lineNumbers: true
      }
    }
  }
});

Development Configuration

// nuxt.config.ts - Development setup
export default defineNuxtConfig({
  content: {
    database: {
      type: 'sqlite',
      sqlite: {
        path: '.nuxt/content-dev.db',
        walMode: true
      }
    },
    
    preview: {
      enabled: true,
      auth: {
        strategy: 'token',
        token: {
          secret: process.env.PREVIEW_SECRET,
          expiresIn: '24h'
        }
      },
      websocket: { enabled: true }
    },
    
    watch: {
      enabled: true,
      patterns: ['content/**/*', 'components/**/*.vue'],
      debounce: 200
    },
    
    experimental: {
      advancedQuery: true,
      serverComponents: true
    }
  }
});

Types

interface LocalDevelopmentDatabase {
  /** Enable local development database */
  enabled?: boolean;
  /** Database file path */
  path?: string;
  /** Auto-migrate on changes */
  migrate?: boolean;
  /** Development-only options */
  devOptions?: {
    logQueries?: boolean;
    resetOnRestart?: boolean;
  };
}

interface CacheEntry {
  /** Cache key */
  key: string;
  /** Cached value */
  value: unknown;
  /** Creation timestamp */
  createdAt: number;
  /** Expiration timestamp */
  expiresAt?: number;
  /** Cache tags for invalidation */
  tags?: string[];
}

type DatabaseBindParams = string | number | boolean | null | Buffer;

Install with Tessl CLI

npx tessl i tessl/npm-nuxt--content

docs

collections.md

configuration.md

index.md

navigation-utilities.md

navigation.md

preview.md

querying.md

rendering.md

runtime-utilities.md

tile.json