How to use the tinacms.useLocalForm function in tinacms

To help you get started, we’ve selected a few tinacms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / web / src / brandkit / Tina.tsx View on Github external
export default function ExamplePage(props) {
  // grab the instance of the CMS to access the registered git API
  const cms = useCMS()

  // add a form to the CMS; store form data in `post`
  const [post, form] = useLocalForm({
    id: props.fileRelativePath,
    label: 'Edit Post', // needs to be unique
    // starting values for the post object
    initialValues: { title: props.title, headline: props.headline, markdown: props.markdown },
    // field definition
    fields: [
      { name: 'title', label: 'Title', component: 'text' },
      { name: 'headline', label: 'Headline', component: 'textarea' },
      {
        name: 'markdown',
        component: 'markdown',
        label: 'Post Body',
        description: 'Edit the body of the post here',
      },
    ], // save & commit the file when the "save" button is pressed
    onSubmit(data) {