From b733a35fe2db14d0b73a5d047e295f8a29088377 Mon Sep 17 00:00:00 2001 From: "tina-cloud-app[bot]" <58178390+tina-cloud-app[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 20:30:07 +0000 Subject: [PATCH 01/11] TinaCMS content update by Kelly Davis --- content/docs/tina-cloud/faq.md | 40 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/content/docs/tina-cloud/faq.md b/content/docs/tina-cloud/faq.md index 1431e8373..8e655d188 100644 --- a/content/docs/tina-cloud/faq.md +++ b/content/docs/tina-cloud/faq.md @@ -11,9 +11,9 @@ Tina Cloud adds a GraphQL API to Tina's open-source content editor allowing it t ## Where do I start? -- Have a look at the updated [Tina Cloud docs](/docs/setup-overview/) and try out a starter. -- [Sign up for Tina Cloud](https://app.tina.io/register)! -- [Find us on Discord](https://discord.com/invite/zumN63Ybpf) +* Have a look at the updated [Tina Cloud docs](/docs/setup-overview/) and try out a starter. +* [Sign up for Tina Cloud](https://app.tina.io/register)! +* [Find us on Discord](https://discord.com/invite/zumN63Ybpf) ## Does Tina Cloud only work with GitHub repositories? @@ -21,10 +21,10 @@ Currently, yes, the first Git provider that Tina Cloud integrates with is GitHub ## How can I share an idea or get help using Tina Cloud? -- If you haven't checked yet, the [docs](/docs/) may have the answer you are looking for! -- Connect with us on [Discord](https://discord.com/invite/zumN63Ybpf). -- We can help you at support@tina.io. Email us if you would like to schedule a chat! -- Chat with us from your Tina Cloud dashboard (there's a chat widget on the bottom right of the browser window). +* If you haven't checked yet, the [docs](/docs/) may have the answer you are looking for! +* Connect with us on [Discord](https://discord.com/invite/zumN63Ybpf). +* We can help you at support@tina.io. Email us if you would like to schedule a chat! +* Chat with us from your Tina Cloud dashboard (there's a chat widget on the bottom right of the browser window). ## What is the pricing for Tina Cloud? @@ -34,7 +34,7 @@ A fair use policy will be coming soon. We will contact you if we believe your use case may eventually fit within our post-beta paid plans. -## **Does Tina Cloud work with Monorepos?** +## Does Tina Cloud work with Monorepos? It does! Tina Cloud can work with sites inside monorepos by specifying the path to your `tina` folder in your Project configuration. @@ -54,12 +54,12 @@ See [Path To Tina](/docs/tina-cloud/dashboard/projects/#path-to-tina) for more i Tina Cloud's GraphQL API returns this error when it cannot find a file in your GitHub repository. This may occur under the following circumstances: -- The `tina` folder (and `__generated__` subfolder) is not in your GitHub repository remote. - - If the folder is in your local repository, but not in your remote, make sure there isn't a `.gitignore` file excluding it. -- Tina is configured with a branch that doesn't exist or a branch that doesn't contain the `tina` folder. - - The referenced branch should be created and should contain the `tina` folder. -- The apiURL prop is misconfigured on the TinaCMS component. - - Check the apiURL and make sure it looks like `https://content.tinajs.io/content/{tina_client_id}/github/{branch}` where `{tina_client_id}` matches the Client ID on the Project in Tina Cloud and `{branch}` is a valid branch. +* The `tina` folder (and `__generated__` subfolder) is not in your GitHub repository remote. + * If the folder is in your local repository, but not in your remote, make sure there isn't a `.gitignore` file excluding it. +* Tina is configured with a branch that doesn't exist or a branch that doesn't contain the `tina` folder. + * The referenced branch should be created and should contain the `tina` folder. +* The apiURL prop is misconfigured on the TinaCMS component. + * Check the apiURL and make sure it looks like `https://content.tinajs.io/content/{tina_client_id}/github/{branch}` where `{tina_client_id}` matches the Client ID on the Project in Tina Cloud and `{branch}` is a valid branch. ## Tina.io login window doesn't close when logging in from a site @@ -67,12 +67,18 @@ When a user logs in from your site, we will pop open a login window. When login The most common reasons for this issue are: -- The Site URL is not properly set for the Tina project. The main window's base URL will need to match the Tina project's Site URL setup in the Tina Cloud Dashboard. -- The Client ID setup in your site's environment variables does not match the Client ID in your project's settings on the Tina Cloud dashboard. -- The user attempting to login to Tina Cloud does not have access to edit this site. Ensure that this user is authorized on the Tina Cloud dashboard. +* The Site URL is not properly set for the Tina project. The main window's base URL will need to match the Tina project's Site URL setup in the Tina Cloud Dashboard. +* The Client ID setup in your site's environment variables does not match the Client ID in your project's settings on the Tina Cloud dashboard. +* The user attempting to login to Tina Cloud does not have access to edit this site. Ensure that this user is authorized on the Tina Cloud dashboard. > Make sure to include `https` in the Site URL eg: https://forestry.io or if you are testing locally, it might be something like `http://localhost:3000` +## How do I resolve "The local GraphQL schema doesn't match the remote GraphQL schema." errors? + +If you are getting this error in your build logs, it means that the tina/tina-lock.json in your deployed site doesn't match the version that is in Tina Cloud. To resolve it, make sure you have latest versions of @tinacms/cli and tinacms in your project, and then run the dev command locally. Commit any changes to the tina/tina-lock.json and push those to the git repository linked in Tina Cloud. + +If you are getting this error when access the TinaCMS interface, it can be caused by a mismatch between the version of tinacms and @tinacms/cli on the project. Update both dependencies to the latest versions and run the dev command locally. Commit any changes to the tina/tina-lock.json and push those to the git repository linked in Tina Cloud. + ## How do I resolve errors caused by unindexed branches? If you receive an error like `The specified branch, 'my-branch-name', has not been indexed by Tina Cloud`, first verify that the correct branch has been specified in From c28fcbd211b9d8452caec33db811815fb3e2bc9d Mon Sep 17 00:00:00 2001 From: James O'Halloran Date: Mon, 24 Jul 2023 21:36:49 -0300 Subject: [PATCH 02/11] Embedded Video tutorial links (#1628) * Embed links to tutorial snippets * more tutorial snippets * schema clip * configuring blocks title update --- content/docs/contextual-editing/overview.md | 10 ++++++++++ content/docs/editing/blocks.md | 11 +++++++++-- .../docs/extending-tina/custom-field-components.md | 10 ++++++++++ content/docs/extending-tina/customize-list-ui.md | 10 ++++++++++ content/docs/features/data-fetching.md | 10 ++++++++++ content/docs/reference/media/overview.md | 12 +++++++++++- content/docs/schema.md | 10 ++++++++++ content/docs/tina-cloud.md | 10 ++++++++++ 8 files changed, 80 insertions(+), 3 deletions(-) diff --git a/content/docs/contextual-editing/overview.md b/content/docs/contextual-editing/overview.md index 7c0edb6fd..3b9265f0f 100644 --- a/content/docs/contextual-editing/overview.md +++ b/content/docs/contextual-editing/overview.md @@ -16,3 +16,13 @@ Tina also allows for "Visual Editing" so that editors can see their pages being ## Adding contextual-editing to a page To add visual editing to a page, you'll need to hydrate the pages data. In React, this is done by [using the `useTina`](/docs/contextual-editing/react) hook. We are currently working on adding support for other frameworks such as [vue](/docs/contextual-editing/vue). + +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on Visual Editing from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
diff --git a/content/docs/editing/blocks.md b/content/docs/editing/blocks.md index c5d31fe6a..c5b74861f 100644 --- a/content/docs/editing/blocks.md +++ b/content/docs/editing/blocks.md @@ -333,5 +333,12 @@ const featureBlock = { } ``` - - +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on "Setting Up Blocks" from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
diff --git a/content/docs/extending-tina/custom-field-components.md b/content/docs/extending-tina/custom-field-components.md index 78e65df43..b18267555 100644 --- a/content/docs/extending-tina/custom-field-components.md +++ b/content/docs/extending-tina/custom-field-components.md @@ -107,3 +107,13 @@ For example, if you take a look at the color field plugin's definition, it takes }, // ... ``` + +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on "Customizing Components" from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
diff --git a/content/docs/extending-tina/customize-list-ui.md b/content/docs/extending-tina/customize-list-ui.md index 218afc466..4f9a01fb2 100644 --- a/content/docs/extending-tina/customize-list-ui.md +++ b/content/docs/extending-tina/customize-list-ui.md @@ -85,3 +85,13 @@ For example: which will render as: ![List UI with label and style prop](https://res.cloudinary.com/forestry-demo/image/upload/v1649941182/tina-io/docs/extending-tina/Extending_Tina_Style_List_Props.png) + +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on "Customizing List Items" from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
diff --git a/content/docs/features/data-fetching.md b/content/docs/features/data-fetching.md index 685394820..e53c5195f 100644 --- a/content/docs/features/data-fetching.md +++ b/content/docs/features/data-fetching.md @@ -64,6 +64,16 @@ When developing locally, it's often beneficial to talk to the content on your lo > If you setup Tina via `@tinacms/cli init`, or used one of our starters, this should be setup by default. (Read about the CLI [here](/docs/graphql/cli/.) +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on "Data Fetching" from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
+ ## Summary - Tina provides a GraphQL API for querying your git-based content. diff --git a/content/docs/reference/media/overview.md b/content/docs/reference/media/overview.md index d349daaa2..de3073529 100644 --- a/content/docs/reference/media/overview.md +++ b/content/docs/reference/media/overview.md @@ -18,7 +18,7 @@ export default defineConfig({ schema: { collections: [ // Array of collections - ] + ], }, media: { // Media config @@ -45,3 +45,13 @@ With the built-in repo-based media option, media is stored within the site's rep TinaCMS also supports pluggable external media providers. [Read more about the external media store implementation here](/docs/reference/media/external/authentication) + +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on media from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
diff --git a/content/docs/schema.md b/content/docs/schema.md index 07ee89f28..01009e3eb 100644 --- a/content/docs/schema.md +++ b/content/docs/schema.md @@ -285,6 +285,16 @@ Each field in a collection can be of the following `type`: - [object](/docs/reference/types/object/) - [rich-text](/docs/reference/types/rich-text/) +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on media from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
+ ## Summary - Your content is modeled in the `tina/config.{ts,js,tsx}` in your repo using `defineConfig`. diff --git a/content/docs/tina-cloud.md b/content/docs/tina-cloud.md index f0e31a2f0..c85bab4b2 100644 --- a/content/docs/tina-cloud.md +++ b/content/docs/tina-cloud.md @@ -31,3 +31,13 @@ To start moving from local-mode to prod-mode, the next steps are to: - Push your repository to GitHub (if it isn't already) - Set up a project in the Tina Cloud dashboard. (See next page) + +## Video Tutorial + +For those who prefer to learn from video, you can check out a snippet on "Tina Cloud" from our ["TinaCMS Deep Dive"](https://www.youtube.com/watch?v=PcgnJDILv4w&list=PLPar4H9PHKVqoCwZy79PHr8-W_vA3lAOB&pp=iAQB) series. + +
+ +
From c78c7e421ebd7691bf3dc8f0ad272764a362adb0 Mon Sep 17 00:00:00 2001 From: James O'Halloran Date: Mon, 24 Jul 2023 23:16:05 -0300 Subject: [PATCH 03/11] tweak video clips --- content/docs/editing/blocks.md | 2 +- content/docs/features/data-fetching.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/editing/blocks.md b/content/docs/editing/blocks.md index c5b74861f..11bfb6d14 100644 --- a/content/docs/editing/blocks.md +++ b/content/docs/editing/blocks.md @@ -339,6 +339,6 @@ For those who prefer to learn from video, you can check out a snippet on "Settin
diff --git a/content/docs/features/data-fetching.md b/content/docs/features/data-fetching.md index e53c5195f..618da0e0e 100644 --- a/content/docs/features/data-fetching.md +++ b/content/docs/features/data-fetching.md @@ -70,7 +70,7 @@ For those who prefer to learn from video, you can check out a snippet on "Data F
From 498fa3e60c279ea8dc0ea86b397616e8fe48ca11 Mon Sep 17 00:00:00 2001 From: Kelly Davis Date: Tue, 25 Jul 2023 11:48:21 -0400 Subject: [PATCH 04/11] fix: stray space --- components/blocks/Actions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/blocks/Actions.tsx b/components/blocks/Actions.tsx index 88cf206cd..26ab816aa 100644 --- a/components/blocks/Actions.tsx +++ b/components/blocks/Actions.tsx @@ -18,7 +18,7 @@ export const Actions = ({ items, align = 'left' }) => { if (item.variant == 'command') { return {item.label} + >{item.label} } const { variant, label, icon, url } = item const externalUrlPattern = /^((http|https|ftp):\/\/)/ From d2f7b0fb466e51ea115facfb56e7ebc0d5b69735 Mon Sep 17 00:00:00 2001 From: James O'Halloran Date: Thu, 27 Jul 2023 14:33:02 -0300 Subject: [PATCH 05/11] Compress Forestry migration guide (#1629) --- content/toc-doc.json | 82 ++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/content/toc-doc.json b/content/toc-doc.json index 9e0eacabe..6091fe960 100644 --- a/content/toc-doc.json +++ b/content/toc-doc.json @@ -290,61 +290,61 @@ { "slug": "/guides/tinacms/react-data-fetching/guide/", "title": "Querying Tina Content at Runtime" - } - ] - }, - { - "title": "Migrating From Forestry", - "slug": "/docs/forestry/overview/", - "items": [ - { - "slug": "/docs/forestry/overview/", - "title": "Overview" - }, - { - "slug": "/docs/forestry/migrate/", - "title": "Setting up Tina" - }, - { - "slug": "/docs/forestry/common-errors/", - "title": "Common Errors & Fixes when Migrating to TinaCMS" }, { - "title": "Comparing Forestry & Tina Concepts", + "title": "Migrating From Forestry", + "slug": "/docs/forestry/overview/", "items": [ { - "slug": "/docs/forestry/accessing-cms/", - "title": "Accessing the CMS" - }, - { - "slug": "/docs/forestry/local-workflow/", - "title": "Local Workflow" - }, - { - "slug": "/docs/forestry/previews/", - "title": "Previews" + "slug": "/docs/forestry/overview/", + "title": "Overview" }, { - "slug": "/docs/forestry/content-modelling/", - "title": "Content Modelling" + "slug": "/docs/forestry/migrate/", + "title": "Setting up Tina" }, { - "slug": "/docs/forestry/drafts/", - "title": "Drafts" + "slug": "/docs/forestry/common-errors/", + "title": "Common Errors & Fixes when Migrating to TinaCMS" }, { - "slug": "/docs/forestry/data-files/", - "title": "Data Files" + "title": "Comparing Forestry & Tina Concepts", + "items": [ + { + "slug": "/docs/forestry/accessing-cms/", + "title": "Accessing the CMS" + }, + { + "slug": "/docs/forestry/local-workflow/", + "title": "Local Workflow" + }, + { + "slug": "/docs/forestry/previews/", + "title": "Previews" + }, + { + "slug": "/docs/forestry/content-modelling/", + "title": "Content Modelling" + }, + { + "slug": "/docs/forestry/drafts/", + "title": "Drafts" + }, + { + "slug": "/docs/forestry/data-files/", + "title": "Data Files" + }, + { + "slug": "/docs/forestry/media/", + "title": "Media" + } + ] }, { - "slug": "/docs/forestry/media/", - "title": "Media" + "slug": "/docs/forestry/missing-forestry-features/", + "title": "Missing Forestry Features" } ] - }, - { - "slug": "/docs/forestry/missing-forestry-features/", - "title": "Missing Forestry Features" } ] }, From 9a606de8ed0d2f8d440121514c583b016780914c Mon Sep 17 00:00:00 2001 From: James O'Halloran Date: Thu, 27 Jul 2023 15:58:13 -0300 Subject: [PATCH 06/11] setu-overview grid cols (#1630) * Emphasize CLI quickstart * simplify grid css --- components/layout/setup-overview.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/layout/setup-overview.tsx b/components/layout/setup-overview.tsx index bc5cc7a99..7b45f4829 100644 --- a/components/layout/setup-overview.tsx +++ b/components/layout/setup-overview.tsx @@ -78,7 +78,7 @@ const OverviewTemplate = (props) => { experience that is perfectly tailored to their site.

-
+
{cards.map((card) => (

{card.header}

@@ -130,7 +130,6 @@ const OverviewTemplate = (props) => { border-radius: 0.75rem; overflow: hidden; display: grid; - grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); width: 100%; border: 1px solid var(--color-seafoam-300); box-shadow: 0 6px 24px rgba(0, 37, 91, 0.05), From 82efd05059532731c593057939741295820161f5 Mon Sep 17 00:00:00 2001 From: Ethan Standel Date: Fri, 28 Jul 2023 14:21:15 -0400 Subject: [PATCH 07/11] fix: tina folder docs for __generated__ items --- content/docs/tina-folder/overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/docs/tina-folder/overview.md b/content/docs/tina-folder/overview.md index 15d3b39a2..64605645e 100644 --- a/content/docs/tina-folder/overview.md +++ b/content/docs/tina-folder/overview.md @@ -52,15 +52,15 @@ This is where all the files that are generated during the schema build process a ### `_graphql.json` -The Graphql AST (represented in JSON). Must be pushed to GitHub. +The Graphql AST (represented in JSON). ### `_lookup.json` -This is a lookup file that is used to resolve document names. Must be pushed to GitHub. +This is a lookup file that is used to resolve document names. ### `_schema.json` -The Graphql Schema AST (represented in JSON). Must be pushed to GitHub. +The Graphql Schema AST (represented in JSON). ### `types.{js,ts}` From 754a903f2097e89a103653d3f11933257f31f50f Mon Sep 17 00:00:00 2001 From: Ethan Standel Date: Fri, 28 Jul 2023 14:32:52 -0400 Subject: [PATCH 08/11] fix: removes unnecessary notes from other __generated__ items --- content/docs/tina-folder/overview.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/docs/tina-folder/overview.md b/content/docs/tina-folder/overview.md index 64605645e..5891dc471 100644 --- a/content/docs/tina-folder/overview.md +++ b/content/docs/tina-folder/overview.md @@ -64,20 +64,20 @@ The Graphql Schema AST (represented in JSON). ### `types.{js,ts}` -This file is where all the types of the schema are generated. This file is for the user to use in there site if they want to use the types. It is generated on every build, and does not need to be pushed to GitHub. +This file is where all the types of the schema are generated. This file is for the user to use in there site if they want to use the types. It is generated on every build. ### `client.{js,ts}` -This file is where all client is generated. This client can be used on the backend and the frontend. It is very lightweight as to not bloat the bundle size. It is generated on every build, and does not need to be pushed to GitHub. [Check out this document](/docs/data-fetching/overview/) for more information on how to use the client. +This file is where all client is generated. This client can be used on the backend and the frontend. It is very lightweight as to not bloat the bundle size. It is generated on every build. [Check out this document](/docs/data-fetching/overview/) for more information on how to use the client. ### `frags.gql` -This file contains the raw Graphql fragments that are generated and used by the [experimental generated client](/docs/data-fetching/overview/). Does not need to be checked into source control. +This file contains the raw Graphql fragments that are generated and used by the [experimental generated client](/docs/data-fetching/overview/). ### `queries.gql` -This file contains the raw graphql queries that are generated and used by the [experimental generated client](/docs/data-fetching/overview/). Does not need to be checked into source control since the the code for the generated client is `tina/__generated__/types.ts`. +This file contains the raw graphql queries that are generated and used by the [experimental generated client](/docs/data-fetching/overview/). ### `schema.gql` -This file contains the raw graphql schema. Does not need to be checked into source control. +This file contains the raw graphql schema. From 0fb16495d31388915a63a7cf38fc7487957fc1d5 Mon Sep 17 00:00:00 2001 From: James O'Halloran Date: Sun, 30 Jul 2023 11:22:01 -0300 Subject: [PATCH 09/11] fix product-tour on firefox (#1632) --- pages/docs/product-tour.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pages/docs/product-tour.tsx b/pages/docs/product-tour.tsx index dcbfb37ff..20e81f6d9 100644 --- a/pages/docs/product-tour.tsx +++ b/pages/docs/product-tour.tsx @@ -48,13 +48,24 @@ export default function Page(props) { if (!activeIds.length) { return } - const imageSrc = ( - document.querySelector( - `h2#${activeIds[0]} ~ *:has(img) img, ` + - `h3#${activeIds[0]} ~ *:has(img) img, ` + - `h4#${activeIds[0]} ~ *:has(img) img` - ) as any - )?.src + + const heading = document.querySelector( + `h2#${activeIds[0]}, h3#${activeIds[0]}, h4#${activeIds[0]}` + ) + let imageSrc = null + + if (heading) { + let sibling = heading.nextElementSibling + + while (sibling) { + const image = sibling.querySelector('img') + if (image) { + imageSrc = image.src + break + } + sibling = sibling.nextElementSibling + } + } // limit activeIds to 1 const deepestActiveIds = activeIds.slice(0, 1) From dfac4f16b527d93b7726095cfd13130db8f049c6 Mon Sep 17 00:00:00 2001 From: Jeff See Date: Mon, 31 Jul 2023 12:52:24 -0700 Subject: [PATCH 10/11] Addendum to Nextjs draft guide that uses branch name for preview data --- .../guides/tinacms/contextual-drafts/guide.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/content/guides/tinacms/contextual-drafts/guide.md b/content/guides/tinacms/contextual-drafts/guide.md index a62b747b3..2bc0b3041 100644 --- a/content/guides/tinacms/contextual-drafts/guide.md +++ b/content/guides/tinacms/contextual-drafts/guide.md @@ -218,3 +218,68 @@ export default App Now when an editor logs in they will enter preview mode and be able to contextual edit draft documents. You can see the [final result here](https://github.com/tinacms/tina-barebones-starter-preview-mode) and if you want to learn more about preview mode [see the Next.js docs](https://nextjs.org/docs/advanced-features/preview-mode). + +## Working with editorial workflows + +If you're using [editorial workflows](https://tina.io/docs/drafts/editorial-workflow/), you'll likely want to ensure that the preview data is fetching content from the branch +you're editing. To enable this, subscribe to the `branch:change` event via the `cmsCallback` function in the config: + +```ts +// tina/config.ts +import { defineConfig } from 'tinacms' + +export default defineConfig({ + // ... + cmsCallback: (cms) => { + cms.events.subscribe('branch:change', async ({ branchName }) => { + console.log(`branch change detected. setting branch to ${branchName}`) + return fetch(`/api/preview/change-branch?branchName=${branchName}`) + }) + return cms + }, +}) +``` + +Add another api endpoint at `/api/preview/change-branch`, which only updates the branch data if we're +in preview mode: + +```ts +// api/preview/change-branch +export default function handler(req, res) { + if (req.preview && req.query?.branchName) { + res.setPreviewData({ branch: req.query.branchName }) + return res.status(200).json({ message: 'Success' }) + } + return res.status(403).json({ message: 'Unauthorized' }) +} +``` + +Update our request to include the branch (if provided) in `getStaticProps`: + +```ts +export const getStaticProps = async ({ + params, + preview = false, + previewData = {}, +}) => { + const { data, query, variables } = await client.queries.post( + { + relativePath: params.slug + '.md', + }, + { + branch: preview && previewData?.branch, + } + ) + + return { + // the post is not found if its a draft and the preview is false + notFound: data?.post?.draft && !preview, + props: { + preview, + data, + query, + variables, + }, + } +} +``` From 76dbe126852d36af02d7f646bbb966944197e212 Mon Sep 17 00:00:00 2001 From: SGiumelli <50744238+SGiumelli@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:44:40 +0200 Subject: [PATCH 11/11] changed datetime type on Example with default item (#1636) --- content/docs/reference/collections.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/reference/collections.md b/content/docs/reference/collections.md index 50feae33b..55549a953 100644 --- a/content/docs/reference/collections.md +++ b/content/docs/reference/collections.md @@ -324,7 +324,7 @@ export default defineConfig({ { label: 'Date', name: 'date', - type: 'date', + type: 'datetime', }, ], },