Rift Logo RiftJS

Rift API Reference

Detailed reference for Rift's core functions, methods, variables, and plugin APIs.

Rift Reference Documentation

Frontmatter Parameters

Explore the metadata fields supported by Rift for content organization and customization.

Frontmatter Example
---
layout: post
permalink: /my-post/
title: "My Post Title"
date: 2025-05-10
tags: ["example", "tutorial"]
---

Collections

Define and manage collections to group and query content effectively.

Collections Example
// Define a collection in Rift
module.exports = {
  collections: {
    posts: (content) => content.filter(item => item.type === 'post')
  }
};

Controllers

Controllers allow you to define custom logic for content rendering.

Controller Example
// Example of a custom controller
module.exports = {
  postsController: (content) => {
    return content.map(post => ({
      ...post,
      summary: post.content.slice(0, 100) // Add a summary field
    }));
  }
};

Localization

Learn how to localize your content for different languages and regions.

Localization Example
// Example of localization configuration
module.exports = {
  localization: {
    defaultLocale: 'en',
    locales: ['en', 'es', 'fr'],
    translations: {
      en: { welcome: 'Welcome' },
      es: { welcome: 'Bienvenido' },
      fr: { welcome: 'Bienvenue' }
    }
  }
};

Context

Understand the context object available in Rift for dynamic content rendering.

Context Example
// Accessing context in a controller
module.exports = {
  exampleController: (context) => {
    console.log(context.params); // Access route parameters
    console.log(context.query);  // Access query parameters
    return context;
  }
};

Content

Learn how to manage and query content files in Rift.

Content Example
// Querying content files
const posts = await getContent('posts/*.md', item => ({
  ...item.metadata,
  content: item.content
}));

Params

Learn how to use route parameters in Rift.

Params Example
// Accessing route parameters
module.exports = {
  exampleController: (context) => {
    const { id } = context.params;
    console.log(`Route parameter: ${id}`);
    return id;
  }
};

Custom Render Functions

Create custom render functions in controllers for advanced content manipulation.

Custom Render Function Example
// Custom render function in a controller
module.exports = {
  customRender: (content) => {
    return content.map(item => ({
      ...item,
      rendered: `

${item.title}

${item.content}` })); } };