{"id":18648781,"url":"https://github.com/mitchmac/tina-cloud-demo","last_synced_at":"2025-11-05T08:30:29.434Z","repository":{"id":145859223,"uuid":"362476772","full_name":"mitchmac/tina-cloud-demo","owner":"mitchmac","description":null,"archived":false,"fork":false,"pushed_at":"2021-06-01T14:08:06.000Z","size":9561,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-27T12:29:48.331Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"tina-cloud-demo.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchmac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-28T13:26:47.000Z","updated_at":"2023-03-07T15:37:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"754a09fe-ee88-4355-8739-f2dc4f007ecf","html_url":"https://github.com/mitchmac/tina-cloud-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchmac%2Ftina-cloud-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchmac%2Ftina-cloud-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchmac%2Ftina-cloud-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchmac%2Ftina-cloud-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchmac","download_url":"https://codeload.github.com/mitchmac/tina-cloud-demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239451026,"owners_count":19640855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T06:33:49.274Z","updated_at":"2025-11-05T08:30:29.381Z","avatar_url":"https://github.com/mitchmac.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tina Cloud Starter 🦙\n\nBasic TinaCMS starter based on [Next.js](https://nextjs.org) and [TinaCMS](https://tina.io) that connects to Tina Cloud Content API.\n\n![Starter Homepage Preview](public/uploads/tina-cloud-starter-preview.png)\n\n## Project scope:\n\n- Run this project locally using local content within this repository.\n- Connect to Tina Cloud to benefit from its GraphQL Content API.\n- Deploy the site to visually edit your site.\n- Invite collaborators.\n\n## Table of contents\n\n- ❓ [What is this?](#what-is-this)\n- 🍴 [Fork and Clone](#fork-and-clone-this-repository)\n- ⬇️ [Install](#install)\n- 🌎 [Run the project locally](#run-the-project-locally)\n- 📝 [Edit content locally](#edit-content-locally)\n- 🦙 [Connect to Tina Cloud](#connect-to-tina-cloud)\n  - ☁️ [Register your local application with Tina Cloud](#register-your-local-application-with-tina-cloud)\n  - 🔌 [Connect your local project with Tina Cloud](#connect-your-local-project-with-tina-cloud)\n  - 📝 [Edit content](#edit-content)\n- ⬆️ [Deploy](#deploy)\n  - ▲ [Vercel](#vercel)\n  - [Netlify](#netlify)\n- 🗂 [Starter structure](#starter-structure)\n- 📐 [Content Modeling](#content-modeling)\n- 💡 [Local development workflow tips](#local-development-workflow-tips)\n\n## What is this?\n\nThis is a [TinaCMS](https://tina.io)-enabled Next.js app, so you can edit your content on a live page. In this project the Tina file-based CMS is used via GraphQL: it's powered by a schema that _you_ define. It not only serves content from Markdown files in your repository, but it also generates TinaCMS forms for you automatically ✨.\n\n## ⚠️ **Fork this repository** ⚠️\n\nStart by **forking** the repositorty and then pull it down to your computer.\n\n## Install\n\n\u003e ℹ️ This project uses `yarn` as a package manager, if `yarn` isn't installed on your machine, open a terminal and run `npm install -g yarn`\n\nInstall the project's dependencies:\n\n```\nyarn install\n```\n\n\u003e ⚠️ If you'd like to use `npm` beware that there is no `package-lock.json` so we can't guarantee the dependencies are the same for you.\n\n## Run the project locally\n\nTo run the local development server:\n\n```\nyarn dev\n```\n\nThis command starts the GraphQL server and the Next.js application in development mode. It also regenerates your schema types for TypeScript and GraphQL so changes to your `.tina` config are reflected immediately.\n\nOne of the most interesting aspects of the Tina Cloud Content API is that it doesn't actually require anything from the Cloud to work locally. Since Tina is by default a Git-backed CMS, everything can be run from your local filesystem via the CLI.\n\nThis is ideal for development workflows and the API is identical to the one used in the cloud, so once you're ready to deploy your application you won't face any challenges there.\n\nOpen [`http://localhost:3000`](http://localhost:3000) in your browser to see your file-based content being loaded from the GraphQL API.\n\n## Edit content locally\n\nWe need to define some local environment variables in order to edit content with Tina.\n\nCopy `.env.local.sample` to `.env.local`:\n```sh\ncp .env.local.sample .env.local\n\n```\n\n`NEXT_PUBLIC_USE_LOCAL_CLIENT` should be set to `1`, other values can be ignored for now.\n\nRestart your server and visit [`http://localhost:3000/admin`](http://localhost:3000/admin`),\nthe same page is displayed but you can notice a pencil icon at the bottom left corner.\n\nClick to open Tina's sidebar which displays a form with fields you can edit and see update live on the page.\nSince we're working locally, saving results in changes to your local filesystem.\n\nFrom here, you're ready to start building your own project, to read a little bit about how this project is structured, and how to modify it to make it your own,\nread the [folder structure](#starter-structure) section below.\n\nWhen you're ready to deploy your site, read on about how you can connect to Tina Cloud and make authenticated changes via our Cloud API.\n\n## Connect to Tina Cloud\n\nWhile the fully-local development workflow is the recommended way for developers to work,\nyou'll obviously want other editors and collaborators to be able to make changes on a hosted website with authentication.\n\n\u003e ℹ️ Changes from the `/admin` route show up on your home page after your site finishes a rebuild.\n\n## Register your local application with Tina Cloud\n\n1. Visit [auth.tina.io](https://auth.tina.io/register), create an organization, and sign in. Make a note of your orgnization name.\n2. Create an app which connects to the GitHub repository you've just forked. Once your app is created, open settings and copy the client ID.\n\n## Connect your local project with Tina Cloud\n\nIn the `env.local` file set:\n\n- `NEXT_PUBLIC_USE_LOCAL_CLIENT` to `0`.\n- `NEXT_PUBLIC_ORGANIZATION_NAME` to your Tina Cloud organization name\n- `NEXT_PUBLIC_TINA_CLIENT_ID` to the Client ID displayed in your Tina Cloud App.\n\nRestart your server and run `yarn dev` again.\n\nOpen [`http://localhost:3000/admin`](http://localhost:3000/admin`)\n\n![](public/uploads/tina-cloud-authorization.png)\n\nThis time a modal asks you to authenticate through Tina Cloud. Upon success, your edits will be sent to the cloud server (and subsequently to GitHub).\n\n#### Edit content\n\nMake some edits through the sidebar and click save.\nChanges are saved in your GitHub repository.\n\nNow that Tina Cloud editing is working correctly, we can deploy the site so that other team members can make edits too.\n\n\u003e ℹ️ Gotcha: since your changes are being synced directly to Github, you'll notice that your non-\"admin\" routes still receive the unedited data from your local filesystem. This is mostly fine since editing with Tina Cloud is designed for hosted environments. But beware that changes to your schema may result in a mismatch between the Tina Cloud API and your local client.\n\n## Deploy\n\n### Vercel\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/)\n\nConnect to your GitHub repository and set the same environment variables as the ones in your `env.local` file:\n\n```\nNEXT_PUBLIC_ORGANIZATION_NAME= \u003cYOUR_ORGANIZATION\u003e\nNEXT_PUBLIC_TINA_CLIENT_ID= \u003cYOUR_CLIENT_ID\u003e\n```\n\n![](public/uploads/vercel-congratulations.png)\n\n🎉 Congratulations, your site is now live!\n\nYou can test that everything is configured correctly by navigating to `[your deployment URL]/admin`,\nlogging in to Tina Cloud, and making some edits. Your changes should be saved to your GitHub repository.\n\n### Netlify\n\n[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/)\n\nConnect to your GitHub repository, click on **advanced** to set the same environment variables as the ones in your `env.local` file:\n\n![](public/uploads/netlify-build-settings.png)\n\n```\nNEXT_PUBLIC_ORGANIZATION_NAME= \u003cYOUR_ORGANIZATION\u003e\nNEXT_PUBLIC_TINA_CLIENT_ID= \u003cYOUR_CLIENT_ID\u003e\n```\n\nSet the **build command** to `yarn build`,\nSet the **publish directory**. To `.next/` .\n\nOnce you're done, click \"Deploy site\".\n\nInstall the [\"Next on Netlify\" plugin](https://www.netlify.com/blog/2020/12/07/announcing-one-click-install-next.js-build-plugin-on-netlify/)\nin order to take advantage of server-side rendering and Next.js preview features.\n\nTrigger a new deploy for changes to take effect.\n\nYou can test that everything is configured correctly by navigating to `[your deployment URL]/admin`,\nlogging in to Tina Cloud, and making some edits. Your changes should be saved to your GitHub repository.\n\n---\n\n## Starter structure\n\nTina Cloud Starter is a [Next.js](https://nextjs.org) application. The file-based routing happens through the `pages` directory.\n\n### `pages/index.tsx`\n\nThis page can be seen at `http://localhost:3000/`, it loads the content from a markdown file which can be found in this repository at `/content/marketing-pages/index.md`. You can edit this page at `http://localhost:3000/admin`\n\nYou'll find this pattern in other areas too, wherever you have a \"public\" page, we've created a equal \"admin\" version, which wraps your page in Tina. This way your public pages don't load any unnecessary Tina code.\n\n### `pages/posts/[filename].tsx`\n\nPosts come from the `content/posts` directory in this repo, and their routes are built with `getStaticPaths` dynamically at build time. Again, editing them with Tina can be done by visiting the \"admin\" version of their URL, so to edit `http://localhost:3000/posts/voteForPedro`, visit `http://localhost:3000/admin/posts/voteForPedro`.\n\n### `components`\n\nMost of the components in this project are very basic and are for demonstration purposes, feel free to replace them with something of your own!\n\n## Content Modeling\n\nWith Tina Cloud there's no need to build forms manually like you would with TinaCMS. Instead, you're required to define a schema which acts as the single source of truth for the shape and structure of your content.\n\nThis is set up for you in `./.tina/schema.ts`, let's break down what this function is doing:\n\n```ts\nimport { defineSchema } from \"tina-graphql-gateway-cli\";\n\nexport default defineSchema({\n  collections: [\n    {\n      label: \"Blog Posts\",\n      name: \"posts\",\n      path: \"content/posts\",\n      templates: [\n        {\n          label: \"Article\",\n          name: \"article\",\n          fields: [\n            {\n              type: \"text\",\n              label: \"Title\",\n              name: \"title\",\n            },\n            {\n              type: \"reference\",\n              label: \"Author\",\n              name: \"author\",\n              collection: \"authors\",\n            },\n          ],\n        },\n      ],\n    },\n  ]\n}\n```\n\n### `defineSchema`\n\nBe sure this is your default export from this file, we'll validate the schema and build out the GraphQL API with it.\n\n### `collections`\n\nThe top-level key in the schema is an array of _collections_, a `collection` informs the API about _where_ to save content. You can see from the example that a `posts` document would be stored in `content/posts`, and it can be the shape of any `template` from the `templates` key.\n\n### `templates`\n\nTemplates are responsible for defining the shape of your content, you'll see in the schema for this starter that we use `templates` for `sections` as well as `blocks`. If you look at the `landingPage` template, you'll notice that it has a set of `blocks`, which are also templates.\n\n## Local development workflow tips\n\n### Typescript\n\nA good way to ensure your components match the shape of your data is to leverage the auto-generated TypeScript types.\nThese are rebuilt when your `.tina` config changes.\n\n### Visual Studio Code\n\n#### GraphQL extension\n\nTina Cloud generates your GraphQL schema automatically. 🪄\n\n[Install GraphQL extension](https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql) to benefit from type auto-completion.\n\n#### Forestry Schema extension\n\n[Install Forestry extension](https://marketplace.visualstudio.com/items?itemName=jeffsee55.forestry-schema) to lint your YAML-based content models.\n\n### Explore the GraphQL API\n\nIf you have a GraphQL client like [Altair](https://altair.sirmuel.design/) go to `http://localhost:4001/graphql` to learn more about our GraphQL API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchmac%2Ftina-cloud-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchmac%2Ftina-cloud-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchmac%2Ftina-cloud-demo/lists"}