Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@contentrain/core

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentrain/core

Core functionality for Contentrain SDK.

latest
npmnpm
Version
4.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
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 05 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