Astro integration for DCS CMS content and SEO management
npm install @duffcloudservices/cms-astrobash
pnpm add @duffcloudservices/cms-astro
`
Usage
$3
`typescript
// astro.config.mjs
import { defineConfig } from 'astro/config'
import dcs from '@duffcloudservices/cms-astro'
export default defineConfig({
integrations: [dcs()],
})
`
$3
`astro
---
// src/pages/index.astro
import { t, getPageSeo, getPageContent } from '@duffcloudservices/cms-astro'
const seo = getPageSeo('home')
const content = getPageContent('home')
---
{seo?.title}
{seo?.openGraph?.image && (
)}
{t('home', 'hero.title', 'Welcome')}
{t('home', 'hero.subtitle', 'Build amazing things')}
{content['cta.text']}
`
$3
Create .dcs/content.yaml:
`yaml
version: 1
global:
nav.home: Home
footer.copyright: © 2026 Company
pages:
home:
hero.title: Welcome to Our Site
hero.subtitle: Build something amazing
cta.text: Get Started
`
Create .dcs/seo.yaml:
`yaml
version: 1
global:
siteName: My Site
defaultTitle: My Site
titleTemplate: "%s | My Site"
images:
ogDefault: /images/og-default.jpg
pages:
home:
title: Welcome
description: The homepage of My Site
`
API
$3
`typescript
dcs({
contentPath: '.dcs/content.yaml', // Path to content file
seoPath: '.dcs/seo.yaml', // Path to SEO file
debug: false, // Enable debug logging
})
`
$3
#### t(page, key, fallback?)
Get text for a specific page and key.
`astro
{t('home', 'hero.title', 'Default Title')}
`
#### getContent()
Get the full content configuration object.
#### getSeo()
Get the full SEO configuration object.
#### getPageContent(page)
Get all content for a page (global merged with page-specific).
`astro
---
const content = getPageContent('home')
---
{Object.entries(content).map(([key, value]) => (
{key}: {value}
))}
`
#### getPageSeo(page, overrides?)
Get resolved SEO for a page with optional overrides.
`astro
---
const seo = getPageSeo('home', { title: 'Custom Title' })
---
{seo?.title}
`
Advanced Usage
$3
`astro
---
// src/layouts/BaseLayout.astro
import { getPageSeo } from '@duffcloudservices/cms-astro'
interface Props {
page: string
titleOverride?: string
}
const { page, titleOverride } = Astro.props
const seo = getPageSeo(page, titleOverride ? { title: titleOverride } : undefined)
---
{seo?.title ?? 'My Site'}
{seo?.description && (
)}
{seo?.canonical && (
)}
``