Platform-Specific Integration Guides

Two simple functions. Direct database access. Perfect SEO.

Next.js Integration (App Router)

Use fetchAllArticles() and fetchArticle() - two simple functions that handle everything.

Step 1: Add Database URL to .env

DATABASE_URL="mongodb+srv://username:password@cluster.mongodb.net/seoMaker"

Step 2: The 2 Core Functions

Copy these to lib/seo-maker-integration.ts:

import { listItems, getItem } from './db';

const dbUrl = process.env.DATABASE_URL!;

// Function 1: Fetch all articles (basic data)
export async function fetchAllArticles(section: string) {
  const articles = await listItems(dbUrl, section);
  return articles.map((article: any) => ({
    id: article.id,
    title: article.title,
    slug: article.slug,
    seo_title: article.seo_title,
    seo_description: article.seo_description,
    featured_image: article.featured_image,
    createdAt: article.createdAt,
    updatedAt: article.updatedAt,
  }));
}

// Function 2: Fetch single article (full content)
export async function fetchArticle(section: string, slug: string) {
  const article = await getItem(dbUrl, section, slug);
  if (!article) return null;
  
  return {
    id: article.id,
    title: article.title,
    slug: article.slug,
    seo_title: article.seo_title,
    seo_description: article.seo_description,
    seo_keywords: article.seo_keywords,
    og_title: article.og_title,
    og_description: article.og_description,
    og_image: article.og_image,
    featured_image: article.featured_image,
    draft_layout_json: article.draft_layout_json,
    published_layout_json: article.published_layout_json,
    createdAt: article.createdAt,
    updatedAt: article.updatedAt,
  };
}

Step 3: List Page (/blogs/page.tsx)

Function 1 + UI Grid Component

import { fetchAllArticles } from '@/lib/seo-maker-integration';
import { ArticleGrid } from '@/components/SeoMaker/ArticleCard';

export default async function BlogsPage() {
  const articles = await fetchAllArticles('blogs');

  return (
    <div className="max-w-6xl mx-auto px-4 py-8">
      <h1 className="text-5xl font-bold mb-8">Blog Posts</h1>
      <ArticleGrid articles={articles} baseUrl="/blogs" />
    </div>
  );
}

Step 4: Single Post (/blogs/[slug]/page.tsx)

Function 2 + Full UI with Auto SEO

import { fetchArticle, generateSeoMetadata } from '@/lib/seo-maker-integration';
import { ArticleRenderer } from '@/components/SeoMaker/ArticleRenderer';
import Link from 'next/link';

type Params = Promise<{ slug: string }>;

export async function generateMetadata({ params }: { params: Params }) {
  const article = await fetchArticle('blogs', (await params).slug);
  return generateSeoMetadata(article);
}

export default async function BlogPost({ params }: { params: Params }) {
  const article = await fetchArticle('blogs', (await params).slug);

  if (!article) return <div>Post Not Found</div>;

  return (
    <article className="max-w-4xl mx-auto px-4 py-8">
      <Link href="/blogs" className="text-indigo-600 mb-8 inline-block">← Back to Posts</Link>
      <h1 className="text-4xl font-bold mb-4">{article.seo_title || article.title}</h1>
      {article.featured_image && (
        <img src={article.featured_image} alt={article.title} className="w-full rounded-2xl shadow-lg mb-8" />
      )}
      <ArticleRenderer content={article.published_layout_json} />
    </article>
  );
}

Done! You're Ready

✅ Function 1: fetchAllArticles() - List pages
✅ Function 2: fetchArticle() - Single posts
✅ SSR rendering for perfect SEO
✅ Auto-generated metadata & structured data