Content
Learn how to manage and query content files in Rift.
// Querying content files
const posts = await getContent('posts/*.md', item => ({
...item.metadata,
content: item.content
}));
Detailed reference for Rift's core functions, methods, variables, and plugin APIs.
Explore the metadata fields supported by Rift for content organization and customization.
---
layout: post
permalink: /my-post/
title: "My Post Title"
date: 2025-05-10
tags: ["example", "tutorial"]
---
Define and manage collections to group and query content effectively.
// Define a collection in Rift
module.exports = {
collections: {
posts: (content) => content.filter(item => item.type === 'post')
}
};
Controllers allow you to define custom logic for content rendering.
// Example of a custom controller
module.exports = {
postsController: (content) => {
return content.map(post => ({
...post,
summary: post.content.slice(0, 100) // Add a summary field
}));
}
};
Learn how to paginate your content for better navigation and user experience.
// Example of pagination logic
module.exports = {
paginate: (items, pageSize) => {
const pages = [];
for (let i = 0; i < items.length; i += pageSize) {
pages.push(items.slice(i, i + pageSize));
}
return pages;
}
};
Learn how to localize your content for different languages and regions.
// Example of localization configuration
module.exports = {
localization: {
defaultLocale: 'en',
locales: ['en', 'es', 'fr'],
translations: {
en: { welcome: 'Welcome' },
es: { welcome: 'Bienvenido' },
fr: { welcome: 'Bienvenue' }
}
}
};
Understand the context object available in Rift for dynamic content rendering.
// 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;
}
};
Learn how to manage and query content files in Rift.
// Querying content files
const posts = await getContent('posts/*.md', item => ({
...item.metadata,
content: item.content
}));
Learn how to use route parameters in Rift.
// Accessing route parameters
module.exports = {
exampleController: (context) => {
const { id } = context.params;
console.log(`Route parameter: ${id}`);
return id;
}
};
Define custom permalinks for your content in Rift.
---
layout: post
permalink: /blog/fuc kyou
title: "My Blog Post"
---
Create custom render functions in controllers for advanced content manipulation.
// Custom render function in a controller
module.exports = {
customRender: (content) => {
return content.map(item => ({
...item,
rendered: `${item.title}
${item.content}`
}));
}
};