### Install @prismicio/client Source: https://prismic.io/docs/technical-reference/prismicio-vue Install @prismicio/client as it is now a peer dependency and must be explicitly installed. ```bash npm install --save @prismicio/client ``` -------------------------------- ### Installation Source: https://prismic.io/docs/technical-reference/prismicio-helpers Install the @prismicio/helpers package using npm. ```APIDOC ## Installation ```bash npm install @prismicio/helpers ``` ``` -------------------------------- ### Install @prismicio/react v3 Source: https://prismic.io/docs/next-slicezone-deprecation-guide Install the latest version of @prismicio/react using npm. ```bash npm install @prismicio/react@^3 ``` -------------------------------- ### Install @prismicio/vue Source: https://prismic.io/docs/technical-reference/prismicio-vue Install the package using npm. Ensure @prismicio/client is also installed as it's a peer dependency. ```bash npm install --save @prismicio/vue @prismicio/client ``` -------------------------------- ### Install @prismicio/migrate Source: https://prismic.io/docs/technical-reference/prismicio-migrate/v0 Install the @prismicio/migrate package using npm. ```bash npm install @prismicio/migrate ``` -------------------------------- ### Example GET Response for an Asset Source: https://prismic.io/docs/asset-api-technical-reference This is an example of the JSON response when retrieving a single asset. ```json { "id":"Zestwpsz31z-H2JI", "url":"https://prismic-io.imgix.net/yourrepo/yourpng.png?auto=format,compress", "filename":"example file name.png", "size":157432, "width":2960, "height":1318, "last_modified":1709911490751, "kind":"image", "extension":"png", "notes":"notes text", "credits":"credits text", "alt":"alt text", "created_at":1709911490751 } ``` -------------------------------- ### Install @prismicio/next v2 Source: https://prismic.io/docs/technical-reference/prismicio-next Install the latest version of @prismicio/next using npm. ```bash npm install @prismicio/next@^2 ``` -------------------------------- ### GraphQL Client Setup for Prismic Source: https://prismic.io/docs/graphql-technical-reference Configure graphql-request client for Prismic. This example shows the client initialization using the GraphQL endpoint and a fetch function. ```tsx // GraphQL Client - prismicio.js import { GraphQLClient } from "graphql-request"; // The rest of the file... export const client = new GraphQLClient( prismic.getGraphQLEndpoint(repositoryName), { fetch: prismicClient.graphqlFetch, method: "get", }, ); ``` -------------------------------- ### Manually Install @prismicio/react Source: https://prismic.io/docs/next-slicezone-deprecation-guide Manually install @prismicio/react and its peer dependency @prismicio/client in any existing React project. ```bash npm install --save @prismicio/react @prismicio/client ``` -------------------------------- ### Manually Install @prismicio/next and @prismicio/client Source: https://prismic.io/docs/technical-reference/prismicio-next/v2 Manually install @prismicio/next and its peer dependency @prismicio/client in any Next.js project. ```sh npm install --save @prismicio/next @prismicio/client ``` -------------------------------- ### Install @prismicio/next Source: https://prismic.io/docs/technical-reference/prismicio-next Install the @prismicio/next package and its peer dependency @prismicio/client. This is typically done when bootstrapping a Next.js project with @slicemachine/init. ```bash npx @slicemachine/init@latest ``` ```bash npm install --save @prismicio/next @prismicio/client ``` -------------------------------- ### Start Development Server for Slice Simulator Source: https://prismic.io/docs/slice Run this command to start your website's development server, which is required for the slice simulator to function. ```bash npm run dev ``` -------------------------------- ### Install @prismicio/helpers Source: https://prismic.io/docs/technical-reference/prismicio-helpers Install the @prismicio/helpers package using npm. This package is required for rendering Prismic content. ```bash npm install @prismicio/helpers ``` -------------------------------- ### Basic Setup for @prismicio/helpers Usage Source: https://prismic.io/docs/technical-reference/prismicio-helpers This snippet shows the basic setup for using @prismicio/helpers, assuming the client and document have already been queried. It includes necessary imports for Prismic client and helpers, and fetch for Node.js. ```javascript import * as prismic from "@prismicio/client"; import * as prismicH from "@prismicio/helpers"; import fetch from "node-fetch"; // Required in Node.js const repositoryName = "your-repository-name"; const client = prismic.createClient(repositoryName, { fetch, }); const init = async () => { const document = await client.getFirst("page"); /* All operations happen here. */ }; init(); ``` -------------------------------- ### Install @prismicio/svelte Source: https://prismic.io/docs/technical-reference/prismicio-svelte/v2 Install the @prismicio/svelte package and its peer dependency @prismicio/client. This is typically done when bootstrapping a SvelteKit project with @slicemachine/init. ```sh npx @slicemachine/init@latest ``` ```sh npm install --save @prismicio/svelte @prismicio/client ``` -------------------------------- ### Install @prismicio/react with Slicemachine Source: https://prismic.io/docs/next-slicezone-deprecation-guide Install the @prismicio/react package as part of bootstrapping a Next.js project using Slicemachine. ```bash npx @slicemachine/init@latest ``` -------------------------------- ### Install @nuxtjs/prismic with Slicemachine Source: https://prismic.io/docs/technical-reference/nuxtjs-prismic/v5 Install the @nuxtjs/prismic package using the Slicemachine initialization command. ```sh npx @slicemachine/init@latest ``` -------------------------------- ### Install Migration Dependencies Source: https://prismic.io/docs/migration Install the required npm packages for Prismic migration: `@prismicio/client`, `@prismicio/migrate`, and `dotenv`. ```bash npm install @prismicio/client @prismicio/migrate dotenv ``` -------------------------------- ### Install @prismicio/vue v6 Source: https://prismic.io/docs/technical-reference/prismicio-vue Install the latest version of @prismicio/vue. This is automatically handled when using @nuxtjs/prismic v5. ```bash npm install --save @prismicio/vue@^6 ``` -------------------------------- ### Manually Install @prismicio/svelte and @prismicio/client Source: https://prismic.io/docs/technical-reference/prismicio-svelte Manually install @prismicio/svelte and its peer dependency @prismicio/client in any existing Svelte project using npm. ```bash npm install --save @prismicio/svelte @prismicio/client ``` -------------------------------- ### Install svelte-cloudinary for SvelteKit Source: https://prismic.io/docs/with-cloudinary Install the official Cloudinary package for SvelteKit to enable optimized image display. ```sh npm install svelte-cloudinary ``` -------------------------------- ### Fetch Content Example (Next.js) Source: https://prismic.io/docs/api Example of how to fetch a page with a specific UID using the @prismicio/client in a Next.js application. ```APIDOC ## Fetch Content Example (Next.js) ### Description This code snippet demonstrates how to initialize the Prismic client and fetch a page using its UID in a Next.js application. ### Method GET (implicitly through client.getByUID) ### Endpoint Not directly exposed, client handles API calls. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript import { createClient } from "@/prismicio"; export default async function Page() { const client = createClient(); // Fetch the "about-us" page const page = await client.getByUID("page", "about-us"); } ``` ### Response #### Success Response (200) - **page** (object) - The fetched page object containing metadata and data. #### Response Example ```json { "id": "YCiUyRUAACQAxfZK", "uid": "about-us", "url": "/about-us", "type": "page", "href": "https://your-repo.cdn.prismic.io/api/v2/documents/search?...", "tags": ["example"], "first_publication_date": "2023-01-01T10:00:00+0000", "last_publication_date": "2023-01-01T10:00:00+0000", "slugs": ["about-us"], "linked_documents": [], "lang": "en-us", "alternate_languages": [], "data": { // ... page fields and slices } } ``` ``` -------------------------------- ### Install @prismicio/svelte v2 Source: https://prismic.io/docs/technical-reference/prismicio-svelte Install the latest version of `@prismicio/svelte` using npm. This version requires Svelte 5. ```bash npm install @prismicio/svelte@^2 ``` -------------------------------- ### Install Prismic CLI Skills Source: https://prismic.io/docs/cli Install the Prismic CLI skills to enable AI agents to interact with the Prismic CLI. ```sh npx skills add --global prismicio/skills ``` -------------------------------- ### @prismicio/client Usage Example Source: https://prismic.io/docs/content-api Demonstrates how to use the @prismicio/client library to interact with the Content API. ```APIDOC ## @prismicio/client Usage ### Description The `@prismicio/client` library simplifies API requests, handling ref fetching and parameter management automatically. ### Code Example ```tsx import * as prismic from "@prismicio/client"; const client = prismic.createClient("your-repo-name"); // Example: Fetch all 'post' documents with pagination const posts = await client.getAllByType("post", { page: 2, pageSize: 5 }); ``` ``` -------------------------------- ### Install Nuxt Prismic v5 and Prismic Client Source: https://prismic.io/docs/technical-reference/nuxtjs-prismic/v5 Install `@nuxtjs/prismic` v5 and `@prismicio/client` as dev dependencies. `@prismicio/client` is now a peer dependency. ```bash npm install --save-dev @nuxtjs/prismic@^5 @prismicio/client ``` -------------------------------- ### Install Cloudinary Node.js SDK Source: https://prismic.io/docs/with-cloudinary Install the Cloudinary Node.js SDK using npm. This is a prerequisite for creating integration endpoints. ```sh npm install cloudinary ``` -------------------------------- ### Install Shopify Storefront API Client Source: https://prismic.io/docs/with-shopify Install the Shopify Storefront API client using npm. This package is required for fetching additional product data beyond basic metadata. ```sh npm install @shopify/storefront-api-client ``` -------------------------------- ### Install dotenv Package Source: https://prismic.io/docs/technical-reference/prismic-ts-codegen This command installs the `dotenv` package, which is used to load environment variables from a `.env` file into `process.env`. ```bash # To install dotenv npm install --save-dev dotenv ``` -------------------------------- ### Install prismic-ts-codegen and @prismicio/types Source: https://prismic.io/docs/technical-reference/prismic-ts-codegen Install the necessary packages for type generation. This command should be run in your Prismic project's root directory. ```bash npm install --save-dev prismic-ts-codegen @prismicio/types ``` -------------------------------- ### Initialize Agentic Migration Starter Source: https://prismic.io/docs/migration Initialize the agentic migration starter project and set up a new Prismic repository. ```bash npx degit https://github.com/prismicio-community/agentic-migration-starter my-project cd my-project npx prismic init ``` -------------------------------- ### GET /assets Source: https://prismic.io/docs/asset-api-technical-reference Retrieve a list of assets from the media library. You can filter assets by type, limit the number of results, specify a starting cursor, and filter by keyword. ```APIDOC ## GET /assets ### Description Retrieve a list of assets from the media library. You can filter assets by type, limit the number of results, specify a starting cursor, and filter by keyword. ### Method GET ### Endpoint https://asset-api.prismic.io/assets ### Parameters #### Query Parameters - **assetType** (string) - Optional - Filter assets by type (e.g., `"all"`, `"image"`). - **limit** (number) - Optional - Maximum number of assets to be returned (e.g. `100`). - **cursor** (string) - Optional - ID of the asset after which to start the query (e.g. `"1682333764A"`). - **keyword** (string) - Optional - A string to filter assets by keyword (in `title`, `filename`, `alt`, `notes` or `credits` fields). ### Response #### Success Response (200) - **id** (string) - The unique identifier of the asset. - **url** (string) - The URL of the asset. - **filename** (string) - The name of the asset file. - **size** (number) - The size of the asset in bytes. - **width** (number) - The width of the asset in pixels (for images). - **height** (number) - The height of the asset in pixels (for images). - **last_modified** (number) - Timestamp of the last modification. - **kind** (string) - The type of the asset (e.g., `"image"`). - **extension** (string) - The file extension of the asset. - **notes** (string) - Notes about the asset. - **credits** (string) - Credits for the asset. - **alt** (string) - Alt text for the asset. - **created_at** (number) - Timestamp of when the asset was created. #### Response Example { "id":"Zestwpsz31z-H2JI", "url":"https://prismic-io.imgix.net/yourrepo/yourpng.png?auto=format,compress", "filename":"example file name.png", "size":157432, "width":2960, "height":1318, "last_modified":1709911490751, "kind":"image", "extension":"png", "notes":"notes text", "credits":"credits text", "alt":"alt text", "created_at":1709911490751 } ``` -------------------------------- ### Example Upload Asset File Query (TypeScript) Source: https://prismic.io/docs/asset-api-technical-reference This TypeScript code snippet demonstrates how to upload a file using the Asset API with axios. Ensure you have fs and axios installed. ```typescript const uploadFile = async (filePath: fs.PathLike, token: string) => { const formData = new FormData(); formData.append("file", fs.createReadStream(filePath)); const response = await axios.post(assetUrl, formData, { headers: { Authorization: `Bearer ${token}`, "Content-Type": "multipart/form-data", repository: instanceRepository, Accept: "application/json", }, }); await delay(2000); return response; }; ``` -------------------------------- ### Global Custom UI Components in Next.js Source: https://prismic.io/docs/fields/rich-text Use this Next.js example as a starting point to create a wrapper component for Prismic Rich Text. Customize default components by merging them with provided components. ```tsx import { PrismicRichText as BasePrismicRichText, PrismicRichTextProps, JSXMapSerializer, } from "@prismicio/react"; const defaultComponents: JSXMapSerializer = { heading1: ({ children }) => (

{children}

), }; export function PrismicRichText({ components, ...props }: PrismicRichTextProps) { return ( ); } ``` -------------------------------- ### Install Updated Packages Source: https://prismic.io/docs/prismicio-vue-v4-migration-guide After updating package.json, run npm install to install the new package versions. ```bash npm install ``` -------------------------------- ### Create client with createClient() Source: https://prismic.io/docs/prismic-client-v6-migration-guide Replace all previous client creation methods with the new `createClient()` function. ```diff - const client = Prismic.client(endpoint) - const client = await Prismic.getApi(endpoint) - const client = await Prismic.api(endpoint) + const client = prismic.createClient(endpoint) ``` -------------------------------- ### Document Filtering Examples Source: https://prismic.io/docs/content-api Examples of constructing query parameters for filtering documents by type and date. ```APIDOC ## Querying Documents ### Description This section details how to construct query parameters for filtering documents in Prismic. ### Method GET ### Endpoint `/api/v2/documents/search` ### Query Parameters - **q** (string) - Required - The encoded query string for filtering documents. ### Request Example (Unencoded) ``` [[at(document.type,"article")]] ``` ### Request Example (Encoded) ``` %5B%5Bat(document.type%2C%22article%22)%5D%5D ``` ### Request Example with Date Filter (Unencoded) ``` [[at(document.type,"article")][date.year(document.last_publication_date,2020)]] ``` ### Request Example with Date Filter (Encoded) ``` %5B%5Bat(document.type%2C%22article%22)%5D%5Bdate.year(document.last_publication_date%2C2020)%5D%5D ``` ### Response #### Success Response (200) - **results** (array) - An array of document objects matching the query. - **total_results_size** (integer) - The total number of documents found. ### API Explorer Test your queries using the API Explorer: `https://your-repo-name.prismic.io/builder/explorer` ``` -------------------------------- ### Initialize a Type Builder Project Source: https://prismic.io/docs/cli Use the init command to integrate Prismic into a new website project. This command installs Prismic's packages and configures your project with a Prismic client and content previews. Replace with your actual repository name. ```sh npx prismic init --repo ``` -------------------------------- ### Initialize Prismic with Existing Repository Source: https://prismic.io/docs/nextjs If you already have a Prismic repository, use the --repo flag with the prismic init command to connect to your existing repository. ```sh npx prismic init --repo your-domain ``` -------------------------------- ### Install @nuxtjs/cloudinary for Nuxt Source: https://prismic.io/docs/with-cloudinary Install the official Cloudinary package for Nuxt.js to enable optimized image display. ```sh npm install @nuxtjs/cloudinary ``` -------------------------------- ### Install next-cloudinary for Next.js Source: https://prismic.io/docs/with-cloudinary Install the official Cloudinary package for Next.js to enable optimized image display. ```sh npm install next-cloudinary ``` -------------------------------- ### Create client with endpoint and options Source: https://prismic.io/docs/prismic-client-v6-migration-guide Use `createClient()` with the endpoint obtained from `getEndpoint()` and optional configuration. ```tsx const endpoint = prismic.getEndpoint("my-repo-name"); const client = prismic.createClient(endpoint); ``` -------------------------------- ### Render Prismic Content with @prismicio/helpers Source: https://prismic.io/docs/technical-reference/prismicio-helpers Example demonstrating how to query content from a Prismic repository using @prismicio/client and render it with @prismicio/helpers. Requires node-fetch for Node.js environments. ```javascript import * as prismic from "@prismicio/client"; import * as prismicH from "@prismicio/helpers"; import fetch from "node-fetch"; // Required if you're running this code in Node.js const repositoryName = "your-repository-name"; const client = prismic.createClient(repositoryName, { fetch, }); const init = async () => { const document = await client.getFirst("page"); const documentAsHTML = prismicH.asHTML(document.data.description); console.log(documentAsHTML); //

This should log your formatted text.

}; init(); ``` -------------------------------- ### HTML Serializer Function Example Source: https://prismic.io/docs/prismic-helpers-v2-migration-guide This is an example of an HTML Serializer function used with `prismic-dom`'s `RichText.asHtml()`. ```tsx import { Element } from "@prismicio/helpers"; function htmlSerializer(type, element, content, children) { switch (type) { case Element.paragraph: { return `

${children}

`; } } } ``` -------------------------------- ### Fetching Documents with @prismicio/client Source: https://prismic.io/docs/content-api Example of using the `@prismicio/client` library to fetch documents by type, abstracting away manual URL construction and ref fetching. ```typescript import * as prismic from "@prismicio/client" const client = prismic.createClient("your-repo-name") const posts = await client.getAllByType("post", { page: 2, pageSize, 5 }) ``` -------------------------------- ### Create Prismic Client and Filter by Date and Type (JavaScript) Source: https://prismic.io/docs/content-api Example using @prismicio/client SDK to create a client and perform a query filtered by date and document type. ```javascript import * as prismic from "@prismicio/client"; const endpoint = prismic.getEndpoint("your-repo-name"); const client = prismic.createClient(endpoint); const init = async () => { client.get({ filters: [ prismic.filter.dateYear("document.last_publication_date", 2020), prismic.filter.at("document.type", "blog-post"), ], }); }; init(); ``` -------------------------------- ### Timestamp field API response example Source: https://prismic.io/docs/fields/timestamp This is an example of how a timestamp field is represented in the Content API response. ```json { "example_timestamp": "2030-01-31:05:00:00+0000" } ``` -------------------------------- ### Using @prismicio/client for Filtering Source: https://prismic.io/docs/content-api Demonstrates how to use the @prismicio/client SDK to build and execute filtered queries. ```APIDOC ## Client-Side Filtering with @prismicio/client ### Description This section shows how to use the Prismic client library in JavaScript to filter documents programmatically. ### Method GET (handled by the client) ### Endpoint (Handled by the client, typically `https://your-repo-name.cdn.prismic.io/api/v2/documents/search`) ### Parameters (Managed by the `prismic.filter` module) ### Request Example (JavaScript) ```tsx import * as prismic from "@prismicio/client"; const endpoint = prismic.getEndpoint("your-repo-name"); const client = prismic.createClient(endpoint); const init = async () => { const results = await client.get({ filters: [ prismic.filter.dateYear("document.last_publication_date", 2020), prismic.filter.at("document.type", "blog-post"), ], }); console.log(results.items); }; init(); ``` ### Response #### Success Response (200) - **items** (array) - An array of document objects matching the query. ### Related Documentation - [@prismicio/client technical reference](https://prismic.io/docs/technical-reference/prismicio-client.md) ``` -------------------------------- ### GraphQL Query - Example Single Document Source: https://prismic.io/docs/graphql-technical-reference An example GraphQL query to fetch a single document by its UID and language. ```APIDOC query ExampleSingleQuery { # query definition example_singleton_type(uid: "example", lang: "en-US") { # root field with arguments example_title } } ``` -------------------------------- ### Set up Prismic Client Source: https://prismic.io/docs/sveltekit/with-slice-machine Centralize your Prismic client setup in `$lib/prismicio.ts`. This includes route resolvers and default client settings. ```typescript import { createClient as baseCreateClient, type Route, } from "@prismicio/client"; import { enableAutoPreviews, type CreateClientConfig, } from "@prismicio/svelte/kit"; import sm from "../../slicemachine.config.json"; export const repositoryName = sm.repositoryName; // TODO: Update with your route resolvers. const routes: Route[] = [ { type: "homepage", path: "/" }, { type: "page", path: "/:uid" }, { type: "blog_post", path: "/blog/:uid" }, ]; export function createClient({ cookies, ...config }: CreateClientConfig = {}) { const client = prismic.createClient(repositoryName, { routes, ...config, }); enableAutoPreviews({ client, cookies }); return client; } ``` -------------------------------- ### JavaScript URL Constructor Example Source: https://prismic.io/docs/content-api Example of using the JavaScript URL constructor to build API request URLs. ```APIDOC ## JavaScript URL Constructor ### Description Utilize the built-in `URL()` constructor in JavaScript to manage search parameters for API requests. ### Code Example ```tsx const url = new URL( "https://your-repo-name.cdn.prismic.io/api/v2/search/documents" ); url.searchParams.append("ref", "X71BaxIAACMA0NsN"); url.searchParams.append("page", 2); url.searchParams.append("pageSize", 5); console.log(url.href); // Output: https://your-repo-name.cdn.prismic.io/api/v2/search/documents?ref=X71BaxIAACMA0NsN&page=2&pageSize=5 ``` ``` -------------------------------- ### Create Prismic Client with Route Resolvers Source: https://prismic.io/docs/route-resolver Initializes the Prismic client with a basic route resolver for blog posts. This example demonstrates fetching a blog post and accessing its generated URL. ```javascript import { createClient } from "@prismicio/client"; const client = createClient("example-prismic-repo", { routes: [ { type: "blog_post", path: "/blog/:uid" }, ], }); const blogPost = await client.getByUID("blog_post", "my-first-post"); blogPost.url; // => "/blog/my-first-post" ``` -------------------------------- ### Create Prismic Client with Configuration Source: https://prismic.io/docs/technical-reference/prismicio-client/v7 Instantiate a Prismic client with your repository name and access token. This is the basic setup for interacting with the Prismic API. ```typescript const client = createClient("example-prismic-repo", { accessToken: "example-access-token", }); ``` -------------------------------- ### Install Internationalization Packages Source: https://prismic.io/docs/sveltekit Install the 'negotiator' and '@formatjs/intl-localematcher' npm packages required for locale detection and matching in your SvelteKit application. ```bash npm install negotiator @formatjs/intl-localematcher ``` -------------------------------- ### Create Prismic Client and Fetch Document Source: https://prismic.io/docs/slice-machine Demonstrates how to create a Prismic client instance and fetch a document by its UID using the client. The fetched document is automatically typed. ```typescript import { createClient } from "@prismicio/client"; const client = createClient("example-prismic-repo"); const blogPost = await client.getByUID("blog_post", "my-first-post"); // ^ Typed as BlogPostDocument ``` -------------------------------- ### Create a SvelteKit Project using Vite Source: https://prismic.io/docs/sveltekit Use this command to scaffold a new SvelteKit project. You can also use an existing project. ```sh npx sv create my-website cd my-website ``` -------------------------------- ### Get Help for Prismic CLI Source: https://prismic.io/docs/cli Use the --help flag to view all available commands and options for the Prismic CLI. ```sh npx prismic --help ``` -------------------------------- ### Full Content API Query with Parameters Source: https://prismic.io/docs/content-api An example of a complete Content API query URL including a ref and multiple search parameters. ```bash https://your-repo-name.cdn.prismic.io/api/v2/documents/search?ref=X71BaxIAACMA0NsN&page=2&pageSize=5 ``` -------------------------------- ### Create a Prismic Client Source: https://prismic.io/docs/technical-reference/prismicio-client Create a Prismic client instance using `createClient`. This client is used for fetching content from a Prismic repository. It requires the repository name and an optional configuration object. ```javascript const client = createClient(repositoryName, config); ``` ```javascript const client = createClient("example-prismic-repo", { accessToken: "example-access-token", }); ``` -------------------------------- ### Get Image URL Source: https://prismic.io/docs/technical-reference/prismicio-helpers Use `asImageSrc` to get the URL of an image field. Image transformations can be applied by passing parameters. ```javascript prismicH.asImageSrc(document.data.example_image); ``` ```javascript prismicH.asImageSrc(document.data.example_image, { sat: -100, }); ``` ```javascript prismicH.asImageSrc(document.data.example_image, { auto: undefined, }); ``` ```javascript prismicH.asImageSrc(document.data.empty_image); ``` -------------------------------- ### Replace `query()` with `get()` Source: https://prismic.io/docs/prismic-client-v6-migration-guide Migrate from `query()` to `get()` by moving predicates into the `predicates` option. This change simplifies query construction. ```diff - const documents = client.query( - Prismic.Predicates.at('document.tags', 'food'), - { lang: 'fr-fr' } - ) + const documents = client.get({ + predicates: prismic.predicate.at('document.tags', 'food'), + lang: 'fr-fr', + }) ``` -------------------------------- ### Basic Content API Query with Ref Source: https://prismic.io/docs/content-api An example of a Content API query URL including a required ref for content versioning. ```bash https://your-repo-name.cdn.prismic.io/api/v2/documents/search?ref=X71BaxIAACMA0NsN ``` -------------------------------- ### HTML Serializer Object Example Source: https://prismic.io/docs/prismic-helpers-v2-migration-guide This is an example of an HTML Serializer object, a new, easier-to-write format for `@prismicio/helpers`'s `asHTML()` function. ```tsx const htmlSerializer = { // Arguments can be destructured for each block type paragraph: ({ children }) => `

${children}

`, }; ``` -------------------------------- ### Get Help for Prismic Commands Source: https://prismic.io/docs/cli Use the --help flag with specific commands or subcommands to get detailed information about their usage. ```sh npx prismic repo --help ``` ```sh npx prismic webhook create --help ``` -------------------------------- ### Repository API Response Example Source: https://prismic.io/docs/repository-api-technical-reference This is an example of the JSON response you can expect when querying the Repository API. It includes details about refs, types, languages, and more. ```json { "refs": [ { "id": "master", "ref": "ZG5h3BAAAB8AhmzJ", "label": "Master", "isMasterRef": true }, { "id": "ZIBvwhAAACMAgx9w", "ref": "ZIBvwxAAACEAgx93~ZIBJVRAAACMAgmBd", "label": "", "scheduledAt": 1696633200000 } ], "bookmarks": {}, "experiments": { "draft": [], "running": [] }, "types": { "home": "Home", "pages": "Pages" }, "languages": [ { "id": "en-us", "name": "English - United States" }, { "id": "en-gb", "name": "English - United Kingdom" } ], "forms": "// Omitted ", "oauth_initiate": "https://your-repo-name.prismic.io/auth", "oauth_token": "https://your-repo-name.prismic.io/auth/token", "tags": [], "license": "All Rights Reserved", "version": "482083b" } ``` -------------------------------- ### Explore Repositories Source: https://prismic.io/docs/mcp Use this prompt to list all repositories you have access to in Prismic. ```markdown What repositories do I have access to in Prismic? ``` -------------------------------- ### Run Prismic CLI without installation Source: https://prismic.io/docs/cli Use this command to run the Prismic CLI directly using npx without needing to install it globally. ```sh npx prismic ``` -------------------------------- ### Initialize Nuxt project with Prismic CLI Source: https://prismic.io/docs/nuxt Use the Prismic CLI to initialize a new Nuxt project with Prismic integration. This command installs necessary packages and configures your project. ```bash npx nuxi@latest init my-website cd my-website ``` ```bash npx prismic init ``` ```bash npx prismic init --repo your-domain ``` -------------------------------- ### Example Payload: Page Published Source: https://prismic.io/docs/webhooks This example demonstrates the structure of a webhook payload when a page is published. The `documents` array will contain the ID of the published page. ```APIDOC ## POST /webhooks/prismic ### Description This is an example of a webhook payload triggered when a page is published. The `documents` array contains the ID of the newly published page. ### Method POST ### Endpoint `/webhooks/prismic` ### Request Body - **type** (string) - Required - Must be "api-update". - **masterRef** (string) - Required - The master ref of the repository. - **releases** (object) - Required - An empty object if no releases were affected. - **masks** (object) - Required - An empty object if no masks were affected. - **tags** (object) - Required - An empty object if no tags were affected. - **experiments** (object) - Required - An empty object if no experiments were affected. - **documents** (string[]) - Required - An array containing the ID of the published page. - **domain** (string) - Required - Your Prismic repository name. - **apiUrl** (string) - Required - The URL of your Prismic repository. - **secret** (string | null) - Optional - The configured secret, if one exists. ### Request Example ```json { "type": "api-update", "masterRef": "X6qn-RIAACMAVge1", "releases": {}, "masks": {}, "tags": {}, "experiments": {}, "documents": ["X6LcjhAAAB8AUJwb"], "domain": "your-repo-name", "apiUrl": "https://your-repo-name.prismic.io/api", "secret": null } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Webhook received successfully." } ``` ``` -------------------------------- ### Get All Custom Types Source: https://prismic.io/docs/custom-types-api Use this GET request to retrieve all custom types from your Prismic repository. Ensure 'repository' and 'Authorization' headers are correctly set. ```bash curl --location --request GET 'https://customtypes.prismic.io/customtypes' \ --header 'repository: tutorial-series' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjM2M3MTAzMTEwMDAwMWYwMGExYTZhMiIsInR5cGUiOiJ1c2VyIiwiZGF0ZSI6MTYxMzczNTY2NzIxNSwiaWF0IjoxNjEzNzM1NjY3fQ.Ex18_cuNtHes69me4pHQGLpiQ-OUbi42-qFxkZCG-yw' ```