Content API Reference
Table of Contents
Overview
The Content Plugin makes it simple to create scalable static content in FastStartup.
It helps you build blogs, guides, help centers, and any other content-heavy pages.
It uses MDX so you can mix Markdown with React components.
The plugin is already set up for you. For example, the blog in app/(landing)/blog
uses it.
Key Features
- Create static content like blog posts, guides, or docs.
- Use MDX for writing content.
- Easily fetch content with a simple API.
- Scale your content as your project grows.
Use Cases
The Content Plugin is perfect for:
- Blogs.
- Help centers.
- Knowledge bases.
- Product documentation.
Anywhere you need organized, scalable content.
Getting Started
Step 1: Organize Your Content
Create a folder where you'll store your MDX files. For example:
app/blog/_posts
This folder will hold all your blog posts as .mdx
files.
Step 2: Fetch Content
To fetch content for a specific blog post, use getPageContent
.
Here's an example in blog/[slug]/page.tsx
:
import { getPageContent } from "@/plugins/content";
export default async function BlogPost({ params }) {
const content = await getPageContent(`src/app/blog/_posts`, params.slug);
return <article>{content}</article>;
}
Step 3: List All Blog Posts
To show a list of all blog posts, use getAllPagesMetadata
.
Example in blog/page.tsx
:
import { getAllPagesMetadata } from "@/plugins/content";
export default async function BlogList() {
const posts = await getAllPagesMetadata("src/app/blog/_posts");
return (
<ul>
{posts.map((post) => (
<li key={post.slug}>
<a href={`/blog/${post.slug}`}>{post.title}</a>
</li>
))}
</ul>
);
}
API Overview
Function | Description |
---|---|
getPageContent | Fetches content of a specific MDX file. |
getAllPagesMetadata | Lists metadata of all MDX files in a folder. |
Comparison to Alternatives
The Content Plugin is built specifically for FastStartup.
Unlike other tools, you don't need extra setup or libraries.
It works out of the box with MDX and fits naturally into your project structure.
With APIs like getPageContent
and getAllPagesMetadata
, you get everything you need to fetch and render content.
FAQ
1. Do I need to install anything?
No. The Content Plugin is already included in FastStartup.
2. Can I use it for non-blog content?
Yes! You can use it for guides, help centers, or any static content.
3. What is MDX?
MDX allows you to write Markdown and use React components in the same file.
4. How do I organize my content?
Create a folder like app/blog/_posts
and store your MDX files there.
5. Is there an example in FastStartup?
Yes. The app/(landing)/blog
folder uses this plugin as an example.