New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@contentrain/core

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@contentrain/core

Core functionality for Contentrain SDK.

1.0.0
unpublished
latest
npm
Version published
Maintainers
0
Created
Source

@contentrain/core

Core functionality for Contentrain SDK.

Installation

npm install @contentrain/core

Usage

import { ContentrainCore } from '@contentrain/core'

// Initialize with default configuration
const core = new ContentrainCore()

// Initialize with custom configuration
const customCore = new ContentrainCore({
  contentPath: 'custom/content/path',
  modelsPath: 'custom/models/path',
  locale: 'en'
})

// Get model metadata
const metadata = await core.getModelMetadata('posts')

// Get content
const posts = await core.getContent('posts')

// Get content by ID
const post = await core.getContentById('posts', '123')

// Get available collections
const collections = await core.getAvailableCollections()

API Reference

Constructor

constructor(config?: ContentrainConfig, customFs?: ContentrainFileSystem)

Creates a new instance of ContentrainCore.

Parameters
  • config (optional): Configuration object

    • contentPath: Path to content directory (default: 'contentrain')
    • modelsPath: Path to models directory (default: 'contentrain/models')
    • assetsPath: Path to assets directory (default: 'contentrain/assets')
    • locale: Locale for content (default: undefined)
  • customFs (optional): Custom filesystem implementation

Methods

getModelMetadata
getModelMetadata(collection: string): Promise<ContentrainModelMetadata>

Gets metadata for a specific collection.

getContent
getContent<T>(collection: string): Promise<T[]>

Gets all content items from a collection.

getContentById
getContentById<T>(collection: string, id: string): Promise<T>

Gets a specific content item by ID.

getAvailableCollections
getAvailableCollections(): Promise<string[]>

Gets a list of all available collections.

getLocale
getLocale(): string | undefined

Gets the current locale setting.

License

MIT

FAQs

Package last updated on 04 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts