### Run Development Server (pnpm/npm) Source: https://github.com/usemarble/astro-example Starts the Astro development server. Access your site at http://localhost:4321. Ensure Node.js and pnpm/npm are installed. ```bash pnpm dev # or npm run dev ``` -------------------------------- ### Create TanStack Start Project Source: https://context7_llms Command to create a new TanStack Start project using npx. Ensure you have Node.js and npm installed. ```bash npx create-start-app@latest ``` -------------------------------- ### Installing Project Dependencies (pnpm/npm/yarn) Source: https://github.com/usemarble/nextjs-example These commands install the project's dependencies using different package managers. Ensure you have one of them installed (pnpm, npm, or yarn). ```bash pnpm install ``` ```bash npm install ``` ```bash yarn install ``` -------------------------------- ### Get all tags Source: https://context7_llms This example shows how to retrieve a paginated list of all tags in your MarbleCMS workspace. It requires an API key for authorization and provides examples in both cURL and JavaScript. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" "https://api.marblecms.com/v1/tags" ``` ```javascript const response = await fetch("https://api.marblecms.com/v1/tags", { headers: { Authorization: "Bearer YOUR_API_KEY" }, }); const data = await response.json(); console.log(data.tags); ``` -------------------------------- ### Install Zod for Input Validation Source: https://context7_llms Installs the Zod library, which is used for runtime data validation in TanStack Start server functions. This ensures data integrity. ```bash npm install zod ``` -------------------------------- ### Install React-Query Dependencies Source: https://github.com/usemarble/tanstack-start-example This command installs the necessary dependencies for using React-Query and its devtools with Bun. React-Query is used for efficient data fetching and caching in React applications. ```bash bun add @tanstack/react-query @tanstack/react-query-devtools ``` -------------------------------- ### Install and Import Marble API Types Source: https://context7.com/websites/marblecms Provides commands to install the official `@usemarble/core` npm package, which includes TypeScript types and Zod schemas for the Marble API. Shows installation for various package managers and how to import types. ```APIDOC ## Install Marble API Types ### Description Install the `@usemarble/core` package to use Marble API's TypeScript types and Zod schemas. ### Installation Commands #### npm ```bash npm install @usemarble/core ``` #### yarn ```bash yarn add @usemarble/core ``` #### pnpm ```bash pnpm add @usemarble/core ``` #### bun ```bash bun add @usemarble/core ``` ### Import Example (TypeScript) ```typescript import { MarblePost } from "@usemarble/core" // Example usage: async function getPostData(): Promise { // ... fetch posts using API const posts: MarblePost[] = []; // replace with actual fetched data return posts; } ``` ``` -------------------------------- ### Example cURL Request and Rate Limit Response Source: https://docs.marblecms.com/api/rate-limits This snippet shows an example of how to make a GET request to the posts endpoint using cURL, including an Authorization header. It also provides an example of a 429 Too Many Requests JSON response when rate limits are exceeded, detailing the error message. ```bash curl -i -H "Authorization: YOUR_API_KEY" "https://api.marblecms.com/v1/posts" ``` ```json { "error": "Too many requests", "details": { "message": "You have exceeded the allowed number of requests. Plea" } } ``` -------------------------------- ### Create TanStack Start App Source: https://context7.com/websites/marblecms Command to create a new TanStack Start project, which is the initial step for setting up the application integrating with MarbleCMS. ```APIDOC ## Create TanStack Start App ### Description Initializes a new TanStack Start project using npx. ### Command ```bash npx create-start-app@latest ``` ``` -------------------------------- ### Post Filtering Examples Source: https://context7_llms Examples demonstrating how to filter posts by category, multiple criteria, retrieve all posts as Markdown, and search posts. ```APIDOC ## GET /v1/posts ### Description Retrieves a list of posts, with options for filtering, sorting, and formatting. ### Method GET ### Endpoint `/v1/posts` ### Query Parameters - **categories** (string) - Optional - Filter posts by one or more categories. - **tags** (string) - Optional - Filter posts by one or more tags. - **limit** (string or integer) - Optional - The maximum number of posts to return. Use 'all' to retrieve all posts. - **format** (string) - Optional - The desired format for the posts. Use 'markdown' for Markdown output. - **query** (string) - Optional - Search posts based on a query string. ### Request Example ```bash # Filter by category curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?categories=tutorials" # Multiple filters curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?categories=tutorials&tags=beginner&limit=5" # Get all posts as Markdown curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?limit=all&format=markdown" # Search posts curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?query=getting%20started" ``` ### Response #### Success Response (200) - **data** (array) - An array of post objects. - **pagination** (object) - Pagination details for navigating through results. #### Response Example ```json { "data": [ { "id": "clt92n38p000108l48zkj41an", "title": "Product Update: March 2024", "slug": "product-update-march-2024", "description": "What's new this month.", "coverImage": "https://cdn.marblecms.com/images/cover.jpg", "publishedAt": "2024-03-05T00:00:00.000Z" } ], "pagination": { "limit": 20, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 8 } } ``` ``` -------------------------------- ### Install TanStack Store Dependency Source: https://github.com/usemarble/tanstack-start-example This command installs the TanStack Store library, which provides a simple and effective way to manage state in React applications. It is used for creating and managing stores. ```bash npm install @tanstack/store ``` -------------------------------- ### Install Tailwind Typography Plugin Source: https://github.com/tailwindlabs/tailwindcss-typography Install the @tailwindcss/typography plugin using npm. This command adds the plugin as a development dependency to your project. ```bash npm install -D @tailwindcss/typography ``` -------------------------------- ### TanStack Start Route for Displaying Posts Source: https://context7.com/websites/marblecms A React component file for a TanStack Start route that fetches and displays a list of posts. It utilizes server functions for data fetching. ```APIDOC ## Route: /posts/ ### Description React component for displaying a list of posts fetched via server functions in a TanStack Start application. ### File `src/routes/posts/index.tsx` (or similar) ### Code Example ```tsx import { createFileRoute } from "@tanstack/react-router"; import { getPosts } from "@/lib/query"; // Assuming getPosts is defined here import { 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(); return (

Posts

); } ``` ``` -------------------------------- ### Success Response Example (JSON) Source: https://context7_llms An example of a successful API response when fetching posts, including the list of posts and pagination details. The 'posts' array contains the data, and 'pagination' provides metadata about the current request. ```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://cdn.marblecms.com/images/cms-guide.webp", "description": "A comprehensive guide to integrating your CMS...", "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://cdn.marblecms.com/avatars/john.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 } } ``` -------------------------------- ### TanStack Start Route for Displaying Posts Source: https://context7.com/websites/marblecms React component file for a TanStack Start route that fetches and displays a list of posts. It utilizes the getPosts server function and create-file-route from @tanstack/react-router. ```tsx import { createFileRoute } from "@tanstack/react-router"; import { getPosts } from "@/lib/query"; import { 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(); ``` -------------------------------- ### Error Response Example Source: https://docs.marblecms.com/api/rate-limits This section provides an example of a typical error response from the API, including status codes and messages. ```APIDOC ## Error Response Example ### Description This is an example of an error response that might be returned by the API. It typically includes a status code and a message indicating the nature of the error. ### Response #### Error Response (e.g., 429) - **statusCode** (integer) - The HTTP status code indicating the error. - **message** (string) - A description of the error. #### Response Example ```json { "statusCode": 429, "message": "Too Many Requests. Please try again after the reset time." } ``` ``` -------------------------------- ### Installing Marble Core npm Package Source: https://docs.marblecms.com/api/types Installs the official npm package `@usemarble/core` which exports TypeScript types and Zod schemas. This avoids manually copying type definitions across projects and ensures they are kept up-to-date with the API. ```bash npm install @usemarble/core ``` ```bash yarn add @usemarble/core ``` ```bash pnpm add @usemarble/core ``` ```bash bun add @usemarble/core ``` -------------------------------- ### API Response Example for a Single Post Source: https://context7.com/websites/marblecms An example of the JSON response received when successfully fetching a single post. It includes details about the post, its author(s), category, and tags. ```APIDOC ## API Response Example for a Single Post ### Description This is an example of the JSON response received when successfully fetching a single post. It includes details about the post, its author(s), category, and tags. ### Method GET ### Endpoint `https://docs.marblecms.com/api/endpoint/post` (Conceptual endpoint for example) ### Response #### Success Response (200) - **post** (object) - An object containing details of a single post. - **id** (string) - The unique identifier of the post. - **slug** (string) - The URL-friendly identifier of the post. - **title** (string) - The title of the post. - **content** (string) - The main content of the post. - **featured** (boolean) - Indicates if the post is featured. - **description** (string) - A brief description of the post. - **coverImage** (string) - URL of the cover image for the post. - **publishedAt** (string) - The publication date and time of the post. - **updatedAt** (string) - The last updated date and time of the post. - **authors** (array) - An array of author objects associated with the post. - **category** (object) - An object representing the post's category. - **tags** (array) - An array of tag objects associated with the post. - **attribution** (object or null) - Attribution details if applicable. #### Response Example ```json { "post": { "id": "clt92n38p000108l48zkj41an", "slug": "introducing-marblecms", "title": "Introducing Marble", "content": "\nHello World!\n============\n\nThis is the content of the post.\n", "featured": true, "description": "The modern headless CMS for modern web applications.", "coverImage": "https://cdn.marblecms.com/images/cover.jpg", "publishedAt": "2024-03-05T00:00:00.000Z", "updatedAt": "2024-03-10T12:00:00.000Z", "authors": [ { "id": "clt92f96m000008l4gken6v2t", "name": "John Doe", "slug": "john-doe", "image": "https://cdn.marblecms.com/avatars/john.jpg", "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." }, "tags": [ { "id": "clt92hrnp000308l4ajp74b32", "name": "Tutorials", "slug": "tutorials", "description": null } ], "attribution": null } } ``` ``` -------------------------------- ### TanStack Start Route to Display Posts Source: https://context7_llms React component for a TanStack Start route that fetches and displays a list of posts using the `getPosts` server function. It utilizes `createFileRoute` for route definition and `Route.useLoaderData` to access the fetched posts. ```tsx import { createFileRoute } from "@tanstack/react-router"; import { getPosts } from "@/lib/query"; import { 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(); ``` -------------------------------- ### Get All Tags Source: https://docs.marblecms.com/api/pagination Retrieves a list of all tags. Supports pagination. ```APIDOC ## GET /tags ### Description Retrieves a list of all tags. Supports pagination via query parameters. ### Method GET ### Endpoint /tags ### Query Parameters - **limit** (integer) - Optional - The maximum number of items to return per page. Default: 10. Range: 1-200. - **page** (integer) - Optional - The page number to retrieve. Pages start at 1. Minimum: 1. ### Response #### Success Response (200) - **tags** (array) - An array of tag objects. - **id** (string) - The unique identifier of the tag. - **name** (string) - The name of the tag. - **pagination** (object) - Metadata about the pagination. - **limit** (integer) - The number of items requested 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 { "tags": [ { "id": "tag_stu123", "name": "API" } ], "pagination": { "limit": 10, "currentPage": 1, "nextPage": null, "previousPage": null, "totalPages": 1, "totalItems": 1 } } ``` ``` -------------------------------- ### Running the Development Server (pnpm/npm/yarn) Source: https://github.com/usemarble/nextjs-example These commands start the Next.js development server, allowing you to view your site locally. After running, access your site at http://localhost:3000. ```bash pnpm dev ``` ```bash npm run dev ``` ```bash yarn dev ``` -------------------------------- ### cURL: Get All Posts with Default Pagination Source: https://docs.marblecms.com/api/pagination This example demonstrates how to retrieve posts using the default pagination settings, which includes 10 items per page and starts from the first page. It requires an Authorization header with your API key. ```cURL curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts" ``` -------------------------------- ### Development Commands (pnpm/npm) Source: https://github.com/usemarble/astro-example Lists available commands for managing the Astro development project, including starting the server, building for production, and previewing the production build locally. ```bash Command | Description ---|--- `pnpm dev` | Start development server at `localhost:4321` `pnpm build` | Build for production to `./dist/` `pnpm preview` | Preview production build locally ``` -------------------------------- ### Cloning the Repository (Git) Source: https://github.com/usemarble/nextjs-example This command clones the Next.js example project repository from GitHub and navigates into the project directory. ```bash git clone https://github.com/usemarble/nextjs-example.git cd nextjs-example ``` -------------------------------- ### Paginated Endpoint: Get Authors Source: https://context7.com/websites/marblecms This documentation refers to the GET endpoint for listing all authors with pagination support. While the full example is truncated, it implies similar structure to other paginated endpoints, including data and pagination details. -------------------------------- ### Setup React-Query Client and Provider Source: https://github.com/usemarble/tanstack-start-example This JavaScript code sets up the QueryClient and QueryClientProvider, which are essential for using React-Query. The provider makes the query client available throughout the React application, typically in 'main.tsx'. ```javascript import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; // ... const queryClient = new QueryClient(); // ... if (!rootElement.innerHTML) { const root = ReactDOM.createRoot(rootElement); root.render( ); } ``` -------------------------------- ### Run Tests with npm Source: https://github.com/usemarble/tanstack-start-example This command executes the test suite for the project using npm. Ensure you have Node.js and npm installed. ```bash npm run test ``` -------------------------------- ### cURL Example: Making an Authenticated API Request Source: https://context7_llms This cURL command demonstrates how to make an authenticated GET request to the MarbleCMS API for posts. It includes the necessary Authorization header with a bearer token. This is a fundamental example for interacting with the API. ```bash curl -i -H "Authorization: Bearer YOUR_API_KEY" "https://api.marblecms.com/v1/posts" ``` -------------------------------- ### GET /v1/posts API Endpoint Example (cURL) Source: https://context7.com/websites/marblecms Retrieves posts from MarbleCMS using a GET request. Supports filtering by categories and tags, limiting the number of results, searching by a query, and specifying the output format. Requires an API key for authorization. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?categories=tutorials&tags=beginner&limit=5" ``` -------------------------------- ### Get a single tag by identifier Source: https://context7_llms This example demonstrates how to retrieve a single tag using its identifier (slug or ID). It requires an API key for authorization and shows both cURL and JavaScript methods for making the request. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/tags/product" ``` ```javascript const response = await fetch("https://api.marblecms.com/v1/tags/product", { headers: { Authorization: "Bearer YOUR_API_KEY" }, }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Project Structure Overview Source: https://github.com/usemarble/astro-example Illustrates the directory structure of the Astro project, highlighting key directories like `src/components`, `src/layouts`, `src/lib`, `src/pages`, and configuration files. ```treeview / ├── src/ │ ├── components/ │ │ ├── PostCard.astro │ │ ├── Prose.astro │ │ └── ... │ ├── layouts/ │ │ └── Layout.astro │ ├── lib/ │ │ ├── queries.ts │ │ ├── schemas.ts │ │ └── constants.ts │ ├── pages/ │ │ ├── index.astro │ │ ├── blog/ │ │ │ ├── index.astro │ │ │ └── [slug].astro │ │ └── tags/ │ ├── content.config.ts │ └── utils/ ├── public/ └── astro.config.mjs ``` -------------------------------- ### Create a Navigation Link Source: https://github.com/usemarble/tanstack-start-example This example demonstrates how to use the imported Link component to create a navigation link to the '/about' route. This facilitates client-side routing without full page reloads. ```jsx About ``` -------------------------------- ### Get All Authors (JavaScript) Source: https://context7_llms Provides an example of retrieving a paginated list of authors using JavaScript's fetch API. The code includes the authorization header and makes a request to the authors endpoint, logging the author data from the response. ```javascript const response = await fetch("https://api.marblecms.com/v1/authors", { headers: { Authorization: "Bearer YOUR_API_KEY" }, }); const data = await response.json(); console.log(data.authors); ``` -------------------------------- ### Setting Up Environment Variables (.env.local) Source: https://github.com/usemarble/nextjs-example This snippet shows how to create a `.env.local` file to configure environment variables required for the MarbleCMS integration, including API URL, API key, and webhook secret. It's crucial to keep your API key secure and not expose it client-side. ```dotenv MARBLE_API_URL=https://api.marblecms.com/v1 MARBLE_API_KEY=your_api_key_here MARBLE_WEBHOOK_SECRET=your_webhook_secret_here ``` -------------------------------- ### cURL: Get Posts with Custom Limit Source: https://docs.marblecms.com/api/pagination This example shows how to fetch posts with a custom limit of 5 items per page. You can adjust the 'limit' query parameter to control the number of items returned. An Authorization header is required. ```cURL curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?limit=5" ``` -------------------------------- ### cURL: Get Specific Page with Custom Limit Source: https://docs.marblecms.com/api/pagination This example demonstrates how to retrieve a specific page of posts (page 2) with a custom limit of 5 items per page. Use the 'page' and 'limit' query parameters to navigate through the dataset. An Authorization header is required. ```cURL curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?page=2&limit=5" ``` -------------------------------- ### Environment Variables Setup Source: https://github.com/usemarble/astro-example Lists essential environment variables for connecting to the MarbleCMS API. `MARBLE_API_URL` is the API endpoint and `MARBLE_API_KEY` is your workspace API key. Never expose the API key in client-side code. ```markdown Variable | Description | Where to Find ---|---|--- `MARBLE_API_URL` | MarbleCMS API endpoint | Default: `https://api.marblecms.com/v1` `MARBLE_API_KEY` | Your workspace API key | Marble Dashboard → Workspace Settings ``` -------------------------------- ### Deploy to Vercel Source: https://github.com/usemarble/astro-example Provides a one-click deployment option to Vercel. After deployment, environment variables (`MARBLE_API_URL`, `MARBLE_API_KEY`) need to be configured in the Vercel project settings. ```markdown Click the button below to deploy this template to Vercel with one click: ![Deploy with Vercel](https://camo.githubusercontent.com/7015516519ae874ab75537283bc75f86b3d46386ed994093a3790a1180913164/68747470733a2f2f76657263656c2e636f6d2f627574746f6e) After deploying, add your environment variables in the Vercel dashboard: 1. Go to your project settings 2. Navigate to Environment Variables 3. Add `MARBLE_API_URL` and `MARBLE_API_KEY` ``` -------------------------------- ### GET Get All Tags Source: https://docs.marblecms.com/api/introduction Retrieves a list of all tags. This endpoint is part of the Tags API. ```APIDOC ## GET /tags ### Description Retrieves a list of all tags. ### Method GET ### Endpoint `/v1/tags` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/tags?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **tags** (array) - An array of tag objects. - **id** (string) - The unique identifier for the tag. - **name** (string) - The name of the tag. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "tags": [ { "id": "tag_1a2b", "name": "API", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### GET Get All Categories Source: https://docs.marblecms.com/api/introduction Retrieves a list of all categories. This endpoint is part of the Categories API. ```APIDOC ## GET /categories ### Description Retrieves a list of all categories. ### Method GET ### Endpoint `/v1/categories` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/categories?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **categories** (array) - An array of category objects. - **id** (string) - The unique identifier for the category. - **name** (string) - The name of the category. - **description** (string) - The description of the category. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "categories": [ { "id": "cat_xyz", "name": "Technology", "description": "Posts about technology.", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Accessing Content Collections in Astro Pages (Astro/JavaScript) Source: https://github.com/usemarble/astro-example Demonstrates how to use `getCollection` from `astro:content` to fetch posts and then map over them to create links. Requires `astro:content` import and assumes a 'posts' collection is defined. ```astro --- import { getCollection } from 'astro:content'; const posts = await getCollection('posts'); ---

Blog Posts

``` -------------------------------- ### GET Get All Authors Source: https://docs.marblecms.com/api/introduction Retrieves a list of all authors. This endpoint is part of the Authors API. ```APIDOC ## GET /authors ### Description Retrieves a list of all authors. ### Method GET ### Endpoint `/v1/authors` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/authors?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **authors** (array) - An array of author objects. - **id** (string) - The unique identifier for the author. - **name** (string) - The name of the author. - **bio** (string) - The biography of the author. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "authors": [ { "id": "author_abc", "name": "John Doe", "bio": "A passionate writer.", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Route with Data Loader using TanStack Router Source: https://github.com/usemarble/tanstack-start-example This example demonstrates fetching data for a route before it renders using TanStack Router's loader functionality. It fetches people data from the SWAPI API and displays their names. The loader function returns a Promise resolving to the JSON data. ```javascript const peopleRoute = createRoute({ getParentRoute: () => rootRoute, path: "/people", loader: async () => { const response = await fetch("https://swapi.dev/api/people"); return response.json() as Promise<{ results: { name: string }[] }>; }, component: () => { const data = peopleRoute.useLoaderData(); return (

People

); }, }); ``` -------------------------------- ### GET Get All Posts Source: https://docs.marblecms.com/api/introduction Retrieves a list of all posts. This endpoint is part of the Posts API. ```APIDOC ## GET /posts ### Description Retrieves a list of all posts. ### Method GET ### Endpoint `/v1/posts` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/posts?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **posts** (array) - An array of post objects. - **id** (string) - The unique identifier for the post. - **title** (string) - The title of the post. - **content** (string) - The content of the post. - **author_id** (string) - The ID of the author. - **category_id** (string) - The ID of the category. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "posts": [ { "id": "post_123", "title": "My First Post", "content": "This is the content of my first post.", "author_id": "author_abc", "category_id": "cat_xyz", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Create and Use a Simple Counter Store Source: https://github.com/usemarble/tanstack-start-example This example demonstrates creating a simple counter using TanStack Store. It initializes a store with a value of 0 and provides a button to increment the counter. The `useStore` hook is used to access and update the store's state within the React component. ```javascript import { useStore } from "@tanstack/react-store"; import { Store } from "@tanstack/store"; import "./App.css"; const countStore = new Store(0); function App() { const count = useStore(countStore); return (

Count: {count}

); } ``` -------------------------------- ### Search posts by keyword Source: https://context7_llms This example illustrates how to search for posts using a keyword. The `query` parameter in the API request allows you to specify your search term. An API key is needed for authentication. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?query=getting%20started" ``` -------------------------------- ### GET /api/endpoint/posts Source: https://context7.com/websites/marblecms Get all published posts with pagination support. Allows filtering by page and limit. ```APIDOC ## GET /api/endpoint/posts ### Description Get all published posts with pagination support. ### 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. ### Response #### Success Response (200) - **data** (array) - An array of post objects. - **pagination** (object) - Pagination information. - **currentPage** (integer) - The current page number. - **totalPages** (integer) - The total number of pages. - **totalItems** (integer) - The total number of items. - **nextPage** (string) - URL for the next page, or null. - **previousPage** (string) - URL for the previous page, or null. #### Response Example ```json { "data": [ { "id": 1, "title": "First Post", "content": "This is the content of the first post." } ], "pagination": { "currentPage": 1, "totalPages": 5, "totalItems": 50, "nextPage": "/api/endpoint/posts?page=2&limit=10", "previousPage": null } } ``` ``` -------------------------------- ### GET Get a Single Tag Source: https://docs.marblecms.com/api/introduction Retrieves a single tag by its ID. This endpoint is part of the Tags API. ```APIDOC ## GET /tags/{id} ### Description Retrieves a single tag by its ID. ### Method GET ### Endpoint `/v1/tags/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the tag. #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/tags/tag_1a2b?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **tag** (object) - The tag object. - **id** (string) - The unique identifier for the tag. - **name** (string) - The name of the tag. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "tag": { "id": "tag_1a2b", "name": "API", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Retrieve all posts in Markdown format Source: https://context7_llms This example shows how to fetch all posts from the MarbleCMS API formatted as Markdown. It uses the `limit=all` parameter to retrieve all content and `format=markdown` for the desired output. Authorization with an API key is required. ```bash curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.marblecms.com/v1/posts?limit=all&format=markdown" ``` -------------------------------- ### GET Get a Single Category Source: https://docs.marblecms.com/api/introduction Retrieves a single category by its ID. This endpoint is part of the Categories API. ```APIDOC ## GET /categories/{id} ### Description Retrieves a single category by its ID. ### Method GET ### Endpoint `/v1/categories/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the category. #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/categories/cat_xyz?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **category** (object) - The category object. - **id** (string) - The unique identifier for the category. - **name** (string) - The name of the category. - **description** (string) - The description of the category. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "category": { "id": "cat_xyz", "name": "Technology", "description": "Posts about technology.", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### GET Get a Single Author Source: https://docs.marblecms.com/api/introduction Retrieves a single author by their ID. This endpoint is part of the Authors API. ```APIDOC ## GET /authors/{id} ### Description Retrieves a single author by their ID. ### Method GET ### Endpoint `/v1/authors/{id}` ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the author. #### Query Parameters - **key** (string) - Required - Your API key. ### Request Example ```bash curl -X GET "https://api.marblecms.com/v1/authors/author_abc?key=YOUR_API_KEY" ``` ### Response #### Success Response (200) - **author** (object) - The author object. - **id** (string) - The unique identifier for the author. - **name** (string) - The name of the author. - **bio** (string) - The biography of the author. - **created_at** (string) - The creation timestamp in UTC ISO 8601 format. - **updated_at** (string) - The update timestamp in UTC ISO 8601 format. #### Response Example ```json { "author": { "id": "author_abc", "name": "John Doe", "bio": "A passionate writer.", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:00:00Z" } } ``` ```