### GET /v1/{workspace_id}/posts Source: https://docs.marblecms.com/api/getting-started This endpoint retrieves all posts from a specified workspace. The example workspace ID can be used for testing without authentication. For production use, include your own workspace key in the URL path for authentication. ```APIDOC ## GET /v1/{workspace_id}/posts ### Description Retrieves a list of all posts from the specified workspace. The workspace ID is included in the URL path, and for the example workspace, no authentication is required. ### Method GET ### Endpoint https://api.marblecms.com/v1/{workspace_id}/posts ### Parameters #### Path Parameters - **workspace_id** (string) - Required - The unique identifier for the workspace. #### Query Parameters None #### Request Body None ### Request Example ```bash curl https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts ``` ### Response #### Success Response (200) - **posts** (array) - List of post objects #### Response Example { "posts": [ { "id": "example_id", "title": "Example Post", "content": "Example content" } ] } ``` -------------------------------- ### Install required dependencies for Marble integration Source: https://docs.marblecms.com/guides/integrations/tanstack Installs the Zod library, which is used for runtime validation of server function inputs. ```bash npm install zod ``` -------------------------------- ### Create TanStack Start project via CLI Source: https://docs.marblecms.com/guides/integrations/tanstack Initializes a new TanStack Start application using the official starter CLI. No additional dependencies are required at this step. ```bash npx create-start-app@latest ``` -------------------------------- ### Generate Static Paths for Individual Posts Source: https://docs.marblecms.com/guides/integrations/astro Astro dynamic route component for displaying individual posts. Implements getStaticPaths() to generate static pages for each post at build time. This snippet shows the initial setup but appears incomplete in the source material. ```astro --- import Layout from '../../layouts/Layout.astro'; import { getCollection } from 'astro:content'; export async function getStaticPaths() { const posts = await getCollection('posts'); ``` -------------------------------- ### Example cURL Request for MarbleCMS API Source: https://docs.marblecms.com/api/rate-limits Demonstrates how to make a GET request to the MarbleCMS API for posts within a specific workspace. This is a common way to interact with the API and may be subject to rate limits. ```bash curl -i "https://api.marblecms.com/v1/YOUR_WORKSPACE_KEY/posts" ``` -------------------------------- ### Create Posts page route to display list of posts Source: https://docs.marblecms.com/guides/integrations/tanstack Defines a TanStack Start file route that loads posts via the getPosts server function and renders them as a list with navigation links. ```tsx import { createFileRoute } from "@tanstack/react-router"; import { getPosts } from "@/lib/query"; { Link } from "@tanstack/react-router"; export const Route = createFileRoute("/posts/")({ component: PostsPage, loader: async () => { const posts = await getPosts(); return posts; }, }); function PostsPage() { const { posts } = Route.useLoaderData(); if (!posts) return
No posts found
; return (

Posts

); } ``` -------------------------------- ### Update Post Page to Use Prose Component Source: https://docs.marblecms.com/guides/integrations/tanstack This updated route integrates the Prose component for styled rendering of post content, building on the initial dynamic route. Depends on Prose component and getSinglePost; inputs slug param, outputs styled post view. Limitation: Enhances aesthetics but requires prior setup of Prose and Tailwind config. ```tsx import { createFileRoute } from "@tanstack/react-router"; import { getSinglePost } from "@/lib/query"; import { Prose } from "@/components/Prose"; export const Route = createFileRoute("/posts/$slug")({ component: PostPage, loader: async ({ params }: { params: { slug: string } }) => { const data = await getSinglePost({ data: params.slug }); return data; }, }); function PostPage() { const { post } = Route.useLoaderData(); if (!post) return
Post not found
; return (

{post.title}

); } ``` -------------------------------- ### Retrieve Post with cURL Source: https://docs.marblecms.com/api/endpoint/post Demonstrates fetching a single post using cURL. This example shows retrieving a post by slug, by ID, and with markdown format as query parameter. The API endpoint accepts either a slug or an ID as the identifier. ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/introducing-marblecms" ``` ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/clt92n38p000108l48zkj41an" ``` ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/introducing-marblecms?format=markdown" ``` -------------------------------- ### Install Tailwind CSS Typography Plugin Source: https://docs.marblecms.com/guides/integrations/nextjs Installs the Tailwind CSS Typography plugin using npm. This is a prerequisite for adding typographic defaults to your content. ```bash npm install -D @tailwindcss/typography ``` -------------------------------- ### Define Marble server functions for data fetching Source: https://docs.marblecms.com/guides/integrations/tanstack Creates TypeScript server functions using TanStack Start's createServerFn to fetch posts, tags, categories, authors, and single post data from the Marble API. Includes Zod validation for slug parameters and full type safety via Marble response types. ```typescript import type { MarbleAuthorListResponse, MarbleCategoryListResponse, MarblePostResponse, MarblePostListResponse, MarbleTagListResponse, } from "@/types/marble"; import { createServerFn } from "@tanstack/react-start"; import { z } from "zod"; const url = process.env.MARBLE_API_URL; const key = process.env.MARBLE_WORKSPACE_KEY; export const getPosts = createServerFn().handler(async () => { try { const raw = await fetch(`${url}/${key}/posts`); const data: MarblePostListResponse = await raw.json(); return data; } catch (error) { console.log(error); } }); export const getTags = createServerFn().handler(async () => { try { const raw = await fetch(`${url}/${key}/tags`); const data: MarbleTagListResponse = await raw.json(); return data; catch (error) { console.log(error); } }); export const getSinglePost = createServerFn() .validator(z.string()) .handler(async ({ data: slug }) => { try { const raw = await fetch(`${url}/${key}/posts/${slug}`); const data: MarblePostResponse = await raw.json(); return data; } catch (error) { console.log(error); } }); export const getCategories = createServerFn().handler(async () => { try { const raw = await fetch(`${url}/${key}/categories`); const data: MarbleCategoryListResponse = await raw.json(); return data; } catch (error) { console.log(error); } }); export const getAuthors = createServerFn().handler(async () => { try { const raw = await fetch(`${url}/${key}/authors`); const data: MarbleAuthorListResponse = await raw.json(); return data; } catch (error) { console.log(error); } }); ``` -------------------------------- ### Configure Marble environment variables Source: https://docs.marblecms.com/guides/integrations/tanstack Adds required Marble API URL and workspace key to a .env file. These variables are accessed only on the server during build and runtime. ```bash MARBLE_API_URL=https://api.marblecms.com/v1 MARBLE_WORKSPACE_KEY=your_workspace_key_here ``` -------------------------------- ### Configure Environment Variables for Marble CMS Source: https://docs.marblecms.com/guides/integrations/astro Sets up required environment variables for Marble API integration. Defines MARBLE_API_URL and MARBLE_WORKSPACE_KEY in a .env file. These variables are loaded server-side during build and should never be exposed to client-side code. ```bash MARBLE_API_URL="https://api.marblecms.com/v1" MARBLE_WORKSPACE_KEY="your_workspace_key_here" ``` -------------------------------- ### Configure Tailwind CSS Typography for v4 (CSS) and v3 (JS) Source: https://docs.marblecms.com/guides/integrations/tanstack These configurations integrate the typography plugin into Tailwind CSS for better content rendering. For v4, import in CSS file; for v3, add to tailwind.config.js. Depends on installed plugin; inputs are config files, outputs styled prose classes. Limitation: Version-specific; choose based on Tailwind version. ```css @import "tailwindcss"; @plugin "@tailwindcss/typography"; ``` ```javascript module.exports = { theme: { // ... }, plugins: [ require("@tailwindcss/typography"), // ... ], }; ``` -------------------------------- ### Install Marble API Types via NPM Source: https://docs.marblecms.com/api/types Installs the official '@usemarble/core' npm package, which exports TypeScript types and Zod schemas for Marble API responses. This method avoids manual copying of type definitions and ensures they are kept up-to-date. ```bash npm install @usemarble/core ``` ```bash yarn add @usemarble/core ``` ```bash pnpm add @usemarble/core ``` ```bash bun add @usemarble/core ``` -------------------------------- ### GET /v1/{workspace_id}/categories Source: https://docs.marblecms.com/api/endpoint/categories Retrieves a list of all categories within a specified workspace. Includes pagination information. ```APIDOC ## GET /v1/{workspace_id}/categories ### Description Retrieves a list of all categories in a workspace. This endpoint is useful for fetching all available categories to display or to use in content filtering. ### Method GET ### Endpoint `/v1/{workspace_id}/categories` ### Parameters #### Path Parameters - **workspace_id** (string) - Required - The unique identifier for the workspace. #### Query Parameters None #### Request Body None ### Request Example ```bash cURL curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/categories" ``` ```javascript Node.js fetch("https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/categories") .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` ### Response #### Success Response (200) - **categories** (array) - A list of category objects. - **id** (string) - The unique identifier for the category. - **name** (string) - The name of the category. - **slug** (string) - A URL-friendly version of the category name. - **description** (string | null) - A brief description of the category. - **count** (object) - An object containing the count of posts associated with the category. - **posts** (integer) - The number of posts in this category. - **pagination** (object) - Information about the pagination of the results. - **limit** (integer) - The maximum number of items per page. - **currentPage** (integer) - The current page number. - **nextPage** (integer | null) - The next page number, or null if on the last page. - **previousPage** (integer | null) - The previous page number, or null if on the first page. - **totalPages** (integer) - The total number of pages available. - **totalItems** (integer) - The total number of items across all pages. #### Response Example ```json { "categories": [ { "id": "clt92hrnp0000i803v0isidst", "name": "Announcements", "slug": "announcements", "description": "Latest news and updates.", "count": { "posts": 5 } }, { "id": "clt92hrnp000108l4ajp74b32", "name": "Tutorials", "slug": "tutorials", "description": null, "count": { "posts": 12 } } ], "pagination": { "limit": 10, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 2 } } ``` ``` -------------------------------- ### Default Pagination Request Source: https://docs.marblecms.com/api/pagination Retrieves the first page of resources with the default limit of 10 items. This is the simplest way to start paginating through data. ```bash curl -X GET 'https://api.marblecms.com/v1/YOUR_WORKSPACE_ID/posts' ``` -------------------------------- ### Example JSON Payload for Post Event in Marble CMS Source: https://docs.marblecms.com/guides/features/webhooks This is an example JSON payload received from Marble CMS for a 'post.published' or 'post.updated' event. It includes the event type and relevant data such as the post's ID, slug, title, and the user ID who made the changes. ```json { "event": "post.published", "data": { "id": "cmf3d1gsv11469tlkp53bcutv", "slug": "getting-started-with-marble", "title": "Getting Started with Marble CMS", "userId": "cms96emp70001l60415sft0i5" } } ``` -------------------------------- ### GET /api/endpoint/posts Source: https://docs.marblecms.com/api/pagination Get all published posts with pagination support. ```APIDOC ## GET /api/endpoint/posts ### Description Retrieves a paginated list of published posts. ### Method GET ### Endpoint /api/endpoint/posts ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of items per page. Defaults to 10, capped between 1 and 200. ### Request Example ```json { "example": "GET /api/endpoint/posts?page=1&limit=10" } ``` ### Response #### Success Response (200) - **posts** (array) - An array of post objects. - **totalPages** (integer) - The total number of pages available. - **totalItems** (integer) - The total number of items available. - **currentPage** (integer) - The current page number. - **nextPage** (integer) - The next page number, or null if it doesn't exist. - **previousPage** (integer) - The previous page number, or null if it doesn't exist. #### Response Example ```json { "posts": [ { "id": 1, "title": "First Post", "content": "..." } ], "totalPages": 5, "totalItems": 50, "currentPage": 1, "nextPage": 2, "previousPage": null } ``` ``` -------------------------------- ### GET /api/endpoint/categories Source: https://docs.marblecms.com/api/pagination Browse all content categories with pagination. ```APIDOC ## GET /api/endpoint/categories ### Description Retrieves a paginated list of content categories. ### Method GET ### Endpoint /api/endpoint/categories ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of items per page. Defaults to 10, capped between 1 and 200. ### Request Example ```json { "example": "GET /api/endpoint/categories?page=1&limit=10" } ``` ### Response #### Success Response (200) - **categories** (array) - An array of category objects. - **totalPages** (integer) - The total number of pages available. - **totalItems** (integer) - The total number of items available. - **currentPage** (integer) - The current page number. - **nextPage** (integer) - The next page number, or null if it doesn't exist. - **previousPage** (integer) - The previous page number, or null if it doesn't exist. #### Response Example ```json { "categories": [ { "id": 1, "name": "Technology" } ], "totalPages": 2, "totalItems": 15, "currentPage": 1, "nextPage": 2, "previousPage": null } ``` ``` -------------------------------- ### Display List of Marble Posts in Astro Source: https://docs.marblecms.com/guides/integrations/astro Astro page component that fetches and displays all posts from the Marble content collection. Uses getCollection() to retrieve posts and renders them as a list with links to individual post pages. Requires the posts content collection to be configured. ```astro --- import Layout from '../../layouts/Layout.astro'; import { getCollection } from 'astro:content'; const posts = await getCollection('posts'); ---

Blog

``` -------------------------------- ### Generate dynamic routes in Astro with MarbleCMS Source: https://docs.marblecms.com/guides/integrations/astro This snippet shows how to dynamically generate routes for blog posts in Astro using data from MarbleCMS. It maps over posts to create route parameters and props for each entry. ```JavaScript return posts.map((entry) => ({ params: { slug: entry.slug }, props: { entry }, })); ``` -------------------------------- ### GET /posts/{identifier} Source: https://docs.marblecms.com/api/endpoint/post Retrieves a single post by its slug or ID. Supports an optional format query parameter to receive content in markdown. ```APIDOC ## GET /posts/{identifier}\n\n### Description\nRetrieves a single post by its identifier (slug or id). Optional query parameter `format` can be set to `markdown` to receive content in markdown instead of HTML.\n\n### Method\nGET\n\n### Endpoint\nhttps://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/{identifier}\n\n### Parameters\n#### Path Parameters\n- **identifier** (string) - Required - The slug or id of the post to retrieve.\n\n#### Query Parameters\n- **format** (string) - Optional - The format of the content field in the response. Set to `markdown` to return the content as markdown instead of HTML.\\n#### Request Body\n_None_\n\n### Request Example\n```bash\ncurl \"https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/introducing-marblecms\"\n```\n\n```bash\ncurl \"https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/clt92n38p000108l48zkj41an\"\n```\n\n```bash\ncurl \"https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/introducing-marblecms?format=markdown\"\n```\n\n### Response\n#### Success Response (200)\n- **post** (object) - The retrieved post object.\n\n#### Response Example\n```json\n{\n \"post\": {\n \"id\": \"clt92n38p000108l48zkj41an\",\n \"slug\": \"introducing-marblecms\",\n \"title\": \"Introducing Marble\",\n \"content\": \"

Hello World!

This is the content of the post.

\",\n \"featured\": true,\n \"description\": \"The modern headless CMS for modern web applications.\",\n \"coverImage\": \"...\",\n \"publishedAt\": \"2024-03-05T00:00:00.000Z\",\n \"authors\": [\n {\n \"id\": \"clt92f96m000008l4gken6v2t\",\n \"name\": \"John Doe\",\n \"slug\": \"john-doe\",\n \"image\": \"...\",\n \"bio\": \"John is a software developer and writer.\",\n \"role\": \"Software Developer\",\n \"socials\": [\n {\n \"url\": \"https://twitter.com/johndoe\",\n \"platform\": \"x\"\n }\n ]\n }\n ],\n \"category\": {\n \"id\": \"clt92hrnp000208l43kbo28d0\",\n \"name\": \"Announcements\",\n \"slug\": \"announcements\",\n \"description\": \"Latest news and updates.\",\n \"count\": {\n \"posts\": 5\n }\n },\n \"tags\": [\n {\n \"id\": \"clt92hrnp000308l4ajp74b32\",\n \"name\": \"Tutorials\",\n \"slug\": \"tutorials\",\n \"description\": null,\n \"count\": {\n \"posts\": 12\n }\n }\n ],\n \"attribution\": null\n }\n}\n```\n ``` -------------------------------- ### Define Content Collection Schema and Loader Source: https://docs.marblecms.com/guides/integrations/astro Creates a typed content collection for Marble posts in Astro. Defines a Zod schema matching the Marble API Post type and implements a loader function that fetches posts from the Marble API. Provides full TypeScript type safety for content consumption. ```typescript import { z, defineCollection } from "astro:content"; import type { MarblePostList } from "./types/marble"; const key = import.meta.env.MARBLE_WORKSPACE_KEY; const url = import.meta.env.MARBLE_API_URL; const PostSchema = z.object({ id: z.string(), slug: z.string(), title: z.string(), content: z.string(), featured: z.boolean(), description: z.string(), coverImage: z.string().url(), publishedAt: z.coerce.date(), updatedAt: z.coerce.date(), authors: z.array( z.object({ id: z.string(), name: z.string(), slug: z.string(), image: z.string().nullable(), bio: z.string().nullable(), role: z.string().nullable(), socials: z.array(SocialSchema), }) ), category: z.object({ id: z.string(), slug: z.string(), name: z.string(), description: z.string().nullable(), }), tags: z.array( z.object({ id: z.string(), slug: z.string(), name: z.string(), description: z.string().nullable(), }) ), attribution: z .object({ author: z.string(), url: z.string().url(), }) .nullable(), }); type Post = z.infer; const postsCollection = defineCollection({ schema: PostSchema, loader: async () => { const response = await fetch(`${url}/${key}/posts`); const { posts }: MarblePostList = await response.json(); return posts.map((post) => ({ ...post, })); }, }); export const collections = { posts: postsCollection, }; ``` -------------------------------- ### GET /api/endpoint/tags Source: https://docs.marblecms.com/api/pagination Retrieve all content tags with pagination. ```APIDOC ## GET /api/endpoint/tags ### Description Retrieves a paginated list of content tags. ### Method GET ### Endpoint /api/endpoint/tags ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of items per page. Defaults to 10, capped between 1 and 200. ### Request Example ```json { "example": "GET /api/endpoint/tags?page=1&limit=10" } ``` ### Response #### Success Response (200) - **tags** (array) - An array of tag objects. - **totalPages** (integer) - The total number of pages available. - **totalItems** (integer) - The total number of items available. - **currentPage** (integer) - The current page number. - **nextPage** (integer) - The next page number, or null if it doesn't exist. - **previousPage** (integer) - The previous page number, or null if it doesn't exist. #### Response Example ```json { "tags": [ { "id": 1, "name": "Web Development" } ], "totalPages": 4, "totalItems": 30, "currentPage": 1, "nextPage": 2, "previousPage": null } ``` ``` -------------------------------- ### Retrieve Post with Node.js Source: https://docs.marblecms.com/api/endpoint/post Shows how to retrieve a post using Node.js and the `fetch` API. The code demonstrates constructing the URL with either a slug or an ID and handling the response. Dependencies include a Node.js runtime environment. ```javascript // You can pass either a slug or an id as the identifier const identifier = "introducing-marblecms"; // or: "clt92n38p000108l48zkj41an" fetch( `https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts/${identifier}` ) .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` -------------------------------- ### Render blog post content in Astro with MarbleCMS Source: https://docs.marblecms.com/guides/integrations/astro This snippet demonstrates rendering a blog post in Astro, including the title, publication date, cover image, and HTML content. It uses Astro.props to access the entry data and set:html for safe HTML rendering. ```JavaScript const { entry } = Astro.props;

{entry.data.title}

Published on: {new Date(entry.data.publishedAt).toLocaleDateString()}

{entry.data.title}
``` -------------------------------- ### Get All Categories - Node.js (fetch) Source: https://docs.marblecms.com/api/endpoint/categories Fetches all categories from a MarbleCMS workspace using the Node.js fetch API. This asynchronous function makes an HTTP GET request and parses the JSON response. Error handling for network issues or invalid responses is included. ```javascript fetch("https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/categories") .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` -------------------------------- ### Get All Categories - cURL Source: https://docs.marblecms.com/api/endpoint/categories Retrieves all categories from a MarbleCMS workspace using a cURL command. This is a simple HTTP GET request to the categories endpoint. No specific input parameters are required other than the workspace ID in the URL. ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/categories" ``` -------------------------------- ### Use Prose Component in Post Page (JSX/React) Source: https://docs.marblecms.com/guides/integrations/nextjs Example of integrating the `Prose` component into a blog post page to render content with enhanced typography. It fetches post data and passes the content to the `Prose` component. ```jsx import { getSinglePost } from "@/lib/query"; import { Prose } from "@/components/prose"; export default async function PostPage({ params }) { const { post } = await getSinglePost(params.slug); return (

{post.title}

); } ``` -------------------------------- ### Successful Paginated Response Source: https://docs.marblecms.com/api/pagination An example of a successful API response containing a list of posts and pagination metadata. It includes details like the current page, next/previous page availability, and total items. ```json { "posts": [ { "id": "post_abc123def456", "slug": "getting-started-with-cms-integration", "title": "Getting Started with CMS Integration", "content": "

Learn how to integrate your content management system...

", "coverImage": "https://images.example.com/media/cms-integration-guide.webp", "description": "A comprehensive guide to integrating your CMS with modern web frameworks...", "publishedAt": "2024-01-15T10:30:00.000Z", "updatedAt": "2024-01-20T14:22:33.456Z", "attribution": null, "authors": [ { "id": "author_xyz789", "name": "John Smith", "image": "https://images.example.com/avatars/john-smith.jpg" } ], "category": { "id": "cat_tutorials123", "name": "Tutorials", "slug": "tutorials" }, "tags": [ { "id": "tag_integration456", "name": "Integration", "slug": "integration" } ] } ], "pagination": { "limit": 5, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 2 } } ``` -------------------------------- ### Example JSON Payload for Tag Deleted Event in Marble CMS Source: https://docs.marblecms.com/guides/features/webhooks This example shows the JSON payload structure for a 'tag.deleted' event from Marble CMS. It contains the event type and the data related to the deleted tag, including its ID, slug, and the user ID responsible for the deletion. ```json { "event": "tag.deleted", "data": { "id": "cmf3d1gsv11469tlkp53bcutv", "slug": "news-and-updates", "userId": "cms96emp70001l60415sft0i5" } } ``` -------------------------------- ### Import Marble API Types from NPM Package Source: https://docs.marblecms.com/api/types Demonstrates how to import Marble API types, such as `MarblePost`, from the installed '@usemarble/core' npm package into your TypeScript project. ```typescript import { MarblePost } from "@usemarble/core" ``` -------------------------------- ### Retrieve All Tags using Node.js Source: https://docs.marblecms.com/api/endpoint/tags This Node.js script fetches all tags from a MarbleCMS workspace using the `fetch` API. It parses the JSON response and logs it to the console. Error handling is included for network or parsing issues. Dependencies: Node.js environment with fetch support. ```javascript fetch("https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/tags") .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` -------------------------------- ### GET /v1/{workspaceId}/tags Source: https://docs.marblecms.com/api/endpoint/tags Retrieves a list of all tags within a specified workspace. This endpoint is useful for fetching all available tags for filtering or display purposes. ```APIDOC ## GET /v1/{workspaceId}/tags ### Description Retrieves a list of all tags in a workspace. ### Method GET ### Endpoint /v1/{workspaceId}/tags ### Parameters #### Path Parameters - **workspaceId** (string) - Required - The unique identifier for the workspace. ### Request Example ```bash cURL curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/tags" ``` ```javascript Node.js fetch("https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/tags") .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` ### Response #### Success Response (200) - **tags** (array) - A list of tag objects, each containing id, name, slug, description, and count. - **pagination** (object) - Pagination details including limit, currentPage, nextPage, previousPage, totalPages, and totalItems. #### Response Example ```json { "tags": [ { "id": "clt92k3c1000408l47h5f0b5y", "name": "Product", "slug": "product", "description": "All about product updates.", "count": { "posts": 8 } }, { "id": "clt92k3c1000508l4gd2p3b8h", "name": "Engineering", "slug": "engineering", "description": null, "count": { "posts": 4 } } ], "pagination": { "limit": 10, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 2 } } ``` ``` -------------------------------- ### GET /api/endpoint/authors Source: https://docs.marblecms.com/api/pagination List all authors with their associated content. ```APIDOC ## GET /api/endpoint/authors ### Description Retrieves a paginated list of authors and their associated content. ### Method GET ### Endpoint /api/endpoint/authors ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of items per page. Defaults to 10, capped between 1 and 200. ### Request Example ```json { "example": "GET /api/endpoint/authors?page=1&limit=10" } ``` ### Response #### Success Response (200) - **authors** (array) - An array of author objects, potentially including content counts or summaries. - **totalPages** (integer) - The total number of pages available. - **totalItems** (integer) - The total number of items available. - **currentPage** (integer) - The current page number. - **nextPage** (integer) - The next page number, or null if it doesn't exist. - **previousPage** (integer) - The previous page number, or null if it doesn't exist. #### Response Example ```json { "authors": [ { "id": 1, "name": "John Doe", "postCount": 5 } ], "totalPages": 3, "totalItems": 25, "currentPage": 1, "nextPage": 2, "previousPage": null } ``` ``` -------------------------------- ### GET /v1/{workspaceId}/posts Source: https://docs.marblecms.com/api/endpoint/posts Retrieves a paginated list of posts within a specific workspace. Supports filtering, sorting, and full-text search. ```APIDOC ## GET /v1/{workspaceId}/posts ### Description Retrieves a paginated list of posts in a workspace. Supports filtering, sorting, and full-text search. ### Method GET ### Endpoint `/v1/{workspaceId}/posts` ### Parameters #### Path Parameters - **workspaceId** (string) - Required - The unique identifier for the workspace. #### Query Parameters - **limit** (integer | "all") - Optional - Default: 10 - Maximum number of items to return. Use `all` to return all posts in a single response. - **page** (integer) - Optional - Default: 1 - Page number to return. Applicable when `limit` is set to a number. - **order** (string) - Optional - Default: desc - Sort order by `publishedAt`. Accepted values: `asc`, `desc`. - **category** (string) - Optional - Filter by category slug. - **tags** (string) - Optional - Comma-separated list of tag slugs to filter by, e.g. `tags=product,engineering`. - **query** (string) - Optional - Full-text search across `title` and `content`. ### Request Example ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/posts?limit=10&page=1&order=desc&category=announcements" ``` ### Response #### Success Response (200) - **posts** (array) - An array of post objects. - **id** (string) - The unique identifier for the post. - **slug** (string) - The URL-friendly identifier for the post. - **title** (string) - The title of the post. - **content** (string) - The HTML content of the post. - **featured** (boolean) - Indicates if the post is featured. - **description** (string) - A short description of the post. - **coverImage** (string) - URL of the cover image. - **publishedAt** (string) - The date and time the post was published (ISO 8601 format). - **authors** (array) - An array of author objects associated with the post. - **category** (object) - The category object for the post. - **tags** (array) - An array of tag objects associated with the post. - **attribution** (any) - Attribution information for the post (can be null). - **pagination** (object) - Pagination details. - **limit** (integer) - The number of items per page. - **currentPage** (integer) - The current page number. - **previousPage** (integer | null) - The previous page number, or null if on the first page. - **nextPage** (integer | null) - The next page number, or null if on the last page. - **totalPages** (integer) - The total number of pages. - **totalItems** (integer) - The total number of items available. #### Response Example ```json { "posts": [ { "id": "clt92n38p000108l48zkj41an", "slug": "introducing-marblecms", "title": "Introducing Marble", "content": "

Hello World!

This is the content of the post.

", "featured": true, "description": "The modern headless CMS for modern web applications.", "coverImage": "...", "publishedAt": "2024-03-05T00:00:00.000Z", "authors": [ { "id": "clt92f96m000008l4gken6v2t", "name": "John Doe", "slug": "john-doe", "image": "...", "bio": "John is a software developer and writer.", "role": "Software Developer", "socials": [ { "url": "https://twitter.com/johndoe", "platform": "x" } ] } ], "category": { "id": "clt92hrnp000208l43kbo28d0", "name": "Announcements", "slug": "announcements", "description": "Latest news and updates.", "count": { "posts": 5 } }, "tags": [ { "id": "clt92k3c1000408l47h5f0b5y", "name": "Tutorials", "slug": "tutorials", "description": null, "count": { "posts": 12 } } ], "attribution": null } ], "pagination": { "limit": 10, "currentPage": 1, "previousPage": null, "nextPage": 2, "totalPages": 13, "totalItems": 125 } } ``` ### Error Handling - **404 Not Found**: If the workspace ID is invalid. - **400 Bad Request**: If query parameters are invalid (e.g., invalid `limit` or `page` values). ``` -------------------------------- ### Implement Prose Component for Styled Content Rendering Source: https://docs.marblecms.com/guides/integrations/tanstack This React component wraps post content with Tailwind Typography classes for improved readability, using dangerouslySetInnerHTML for HTML. Depends on cn utility (e.g., clsx) and Tailwind; inputs include HTML string or children, outputs styled article element. Limitation: Assumes sanitized HTML input; customize classes as needed. ```tsx import { cn } from "@/lib/utils"; import type { HTMLAttributes } from "react"; type ProseProps = HTMLAttributes & { as?: "article"; html: string; }; export function Prose({ children, html, className }: ProseProps) { return (
{html ?
: children}
); } ``` -------------------------------- ### Retrieve All Tags using cURL Source: https://docs.marblecms.com/api/endpoint/tags This snippet demonstrates how to fetch all tags from a MarbleCMS workspace using a cURL command. It requires the base API URL and your workspace ID. The output is a JSON object containing a list of tags and pagination information. ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/tags" ``` -------------------------------- ### GET /v1/:workspaceId/authors Source: https://docs.marblecms.com/api/endpoint/authors Retrieves a list of all authors in a specified workspace. This endpoint is useful for displaying author information or managing author profiles within the CMS. ```APIDOC ## GET /v1/:workspaceId/authors ### Description Retrieves a list of all authors in a workspace. ### Method GET ### Endpoint `/v1/:workspaceId/authors` ### Parameters #### Path Parameters - **workspaceId** (string) - Required - The unique identifier for the workspace. #### Query Parameters None #### Request Body None ### Request Example ```bash curl "https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/authors" ``` ```javascript fetch("https://api.marblecms.com/v1/cm6ytuq9x0000i803v0isidst/authors") .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error("error:" + err)); ``` ### Response #### Success Response (200) - **authors** (array) - A list of author objects. - **id** (string) - The unique identifier for the author. - **name** (string) - The name of the author. - **image** (string) - The URL of the author's image. - **slug** (string) - A URL-friendly version of the author's name. - **bio** (string) - A short biography of the author. - **role** (string) - The author's role within the workspace. - **socials** (array) - A list of the author's social media links. - **url** (string) - The URL of the social media profile. - **platform** (string) - The name of the social media platform. - **count** (object) - Contains counts related to the author's content. - **posts** (integer) - The number of posts authored by this author. - **pagination** (object) - Information about the pagination of the results. - **limit** (integer) - The maximum number of items per page. - **currentPage** (integer) - The current page number. - **nextPage** (integer | null) - The next page number, or null if on the last page. - **previousPage** (integer | null) - The previous page number, or null if on the first page. - **totalPages** (integer) - The total number of pages. - **totalItems** (integer) - The total number of items across all pages. #### Response Example ```json { "authors": [ { "id": "clt92f96m000008l4gken6v2t", "name": "John Doe", "image": "...", "slug": "john-doe", "bio": "John is a software developer and writer.", "role": "Software Developer", "socials": [ { "url": "https://twitter.com/johndoe", "platform": "x" } ], "count": { "posts": 0 } } ], "pagination": { "limit": 10, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 1 } } ``` ```