SDK Reference
Index

SDK Reference

The FeedGen CMS SDK provides a clean, abstracted API for developing themes and plugins.

Quick Reference

In Themes

The SDK is available as sdk in all templates:

{# Get latest posts #}
{% const posts = await sdk.content.getLatestPosts(5); %}
 
{# Format date #}
<time>{{ sdk.utils.formatDate(post.createdAt) }}</time>
 
{# Render pagination #}
{{{ sdk.ui.pagination({ currentPage: 1, totalPages: 10, baseUrl: '/posts' }) }}}

In Plugins

The SDK is passed to your plugin function:

index.js
module.exports = async function(sdk) {
  
  // Content
  const posts = await sdk.content.getLatestPosts(10);
  
  // Hooks
  sdk.hooks.addFilter('post.title', (title) => title.toUpperCase());
  
  // Shortcodes
  sdk.shortcodes.register('hello', () => '<p>Hello!</p>');
  
  // Storage
  await sdk.storage.set('key', { data: 'value' });
  
  return { activate: async () => {}, deactivate: async () => {} };
};

For complete documentation of each API, select from the sidebar or cards above.