Examples
Real-world examples of using the Contessa CMS SDK
Fetch Published Blog Posts
const sdk = new MybeSDK({ apiKey: 'your-api-key' });
const posts = await sdk.getContentByType('blog-post-type-id', {
status: 'published',
limit: 10
});
posts.data.forEach(post => {
console.log(post.data.title);
console.log(post.data.content);
});Multi-locale Content
Fetch content in different languages:
// Fetch English content
const englishPosts = await sdk.getContentByType('blog-post-type-id', {
status: 'published',
locale: 'en-US',
limit: 10
});
// Fetch Bangla content
const banglaPosts = await sdk.getContentByType('blog-post-type-id', {
status: 'published',
locale: 'bn-BD',
limit: 10
});
// Fetch French content
const frenchPosts = await sdk.getContentByType('blog-post-type-id', {
status: 'published',
locale: 'fr-FR',
limit: 10
});Building a Multi-language Website
// Get user's preferred language
const userLocale = getUserPreferredLocale(); // e.g., 'bn-BD'
// Fetch content in user's language
const localizedContent = await sdk.getContentByType('content-type-id', {
status: 'published',
locale: userLocale,
limit: 20
});
// Display localized content
localizedContent.data.forEach(item => {
console.log(item.data.title); // Title in user's language
console.log(item.metadata.locale); // e.g., 'bn-BD'
});Supported Locales
- •
en-US- English (United States) - •
bn-BD- Bangla (Bangladesh) - •
fr-FR- French (France) - •
es-ES- Spanish (Spain) - • Custom locales as configured in your CMS