@duffcloudservices/cms-core
v0.1.1
Published
Shared types and utilities for DCS CMS framework packages
Maintainers
Readme
@duffcloudservices/cms-core
Shared types and utilities for DCS CMS framework packages.
Overview
This package provides the foundation that all framework-specific CMS packages depend on:
- Types: TypeScript definitions for content.yaml, seo.yaml, and pages.yaml
- Content utilities: Functions to resolve text keys across global and page-specific content
- SEO utilities: Functions to resolve and merge SEO configuration
- YAML loaders: Functions to load and parse DCS configuration files
- Runtime fetching: Functions to fetch content from the DCS API (premium tier)
Installation
pnpm add @duffcloudservices/cms-coreUsage
Content Resolution
import { resolveTextKey, getPageContent } from '@duffcloudservices/cms-core'
import type { ContentConfiguration } from '@duffcloudservices/cms-core'
const content: ContentConfiguration = {
version: 1,
global: {
'nav.home': 'Home',
'footer.copyright': '© 2026 Company',
},
pages: {
home: {
'hero.title': 'Welcome',
'hero.subtitle': 'Build amazing things',
},
},
}
// Resolve a single key
const title = resolveTextKey(content, 'home', 'hero.title') // 'Welcome'
const nav = resolveTextKey(content, 'home', 'nav.home') // 'Home' (from global)
// Get all content for a page (merged)
const homeContent = getPageContent(content, 'home')
// { 'nav.home': 'Home', 'footer.copyright': '...', 'hero.title': '...', ... }SEO Resolution
import { resolveSeoForPage, buildMetaTags } from '@duffcloudservices/cms-core'
import type { SeoConfiguration } from '@duffcloudservices/cms-core'
const seo: SeoConfiguration = {
version: 1,
global: {
siteName: 'My Site',
defaultTitle: 'My Site',
titleTemplate: '%s | My Site',
},
pages: {
home: {
title: 'Welcome',
description: 'The homepage of My Site',
},
},
}
// Resolve SEO for a page
const resolved = resolveSeoForPage(seo, 'home')
// { title: 'Welcome | My Site', description: '...', ... }
// Build meta tags array
const tags = buildMetaTags(resolved)
// [{ name: 'description', content: '...' }, { property: 'og:title', ... }]YAML Loading (Build-time)
import { loadContentYaml, loadSeoYaml } from '@duffcloudservices/cms-core'
const content = await loadContentYaml('.dcs/content.yaml')
const seo = await loadSeoYaml('.dcs/seo.yaml')Runtime Fetching (Premium)
import { fetchRuntimeContent } from '@duffcloudservices/cms-core'
// Premium tier only - returns null for non-premium sites
const content = await fetchRuntimeContent('my-site-slug', {
apiBaseUrl: 'https://api.duffcloudservices.com',
})Framework Packages
This core package is used by:
@duffcloudservices/cms-vue- Vue 3 composables + Vite plugins@duffcloudservices/cms-react- React hooks + Vite plugins@duffcloudservices/cms-angular- Angular services + build scripts@duffcloudservices/cms-astro- Astro integration
License
MIT
