Get Post by Slug
Fetch a single blog post with full content.
Updated
On this page
Overview
Fetch a single blog post with its full HTML content.
SDK Usage
import dash from "@/lib/dash"
const { post } = await dash.blog.get("my-first-post", {
trackViews: "session", // "session" | "always" | "none"
})
Post Object
{
"id": "post_abc123",
"title": "Introducing Our New Edibles Line",
"slug": "introducing-new-edibles-line",
"excerpt": "Discover our latest edibles collection...",
"content": "<p>Full HTML blog post content here...</p>",
"author": "CodeCraft Team",
"category": { "id": "cat_blog1", "name": "News", "slug": "news" },
"tags": ["edibles", "new-products", "announcement"],
"featured_image": "https://cdn.dashfordevs.com/...",
"is_featured": true,
"published_at": "2025-01-15T10:00:00Z",
"created_at": "2025-01-10T09:00:00Z",
"custom_fields": {}
}
Blog Post Page
// app/blog/[slug]/page.tsx
import dash from "@/lib/dash"
export default async function BlogPost({ params }) {
const { post } = await dash.blog.get(params.slug)
return (
<article className="max-w-3xl mx-auto py-12">
<h1 className="text-3xl font-bold">{post.title}</h1>
<div className="text-gray-400 mt-2">
By {post.author} · {new Date(post.published_at).toLocaleDateString()}
</div>
{post.featured_image && (
<img src={post.featured_image} alt={post.title} className="mt-6 rounded" />
)}
<div className="prose mt-8" dangerouslySetInnerHTML={{ __html: post.content }} />
</article>
)
}
// Generate SEO metadata
export async function generateMetadata({ params }) {
const { seo } = await dash.blog.getSeo(params.slug)
return {
title: seo.title,
description: seo.description,
openGraph: { images: [seo.og_image] },
}
}
Blog SEO
Fetch SEO metadata separately for Next.js generateMetadata:
const { seo } = await dash.blog.getSeo("my-first-post")
// seo = { title, description, keywords, og_image, canonical_slug }
See Blog SEO for details.
REST API
GET /storefront/blog/posts/my-first-post
X-API-Key: pk_live_your_key
GET /storefront/seo/blog/my-first-post
X-API-Key: pk_live_your_key
Next Steps
- List Posts — Blog listing with filters
- Blog SEO — Meta tags for blog posts
- Recipe: Build a Blog — Complete blog walkthrough