New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

next-tinacms-json

Package Overview
Dependencies
Maintainers
11
Versions
308
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-tinacms-json

  • 0.0.0-202201022290
  • tailwind
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-92.5%
Maintainers
11
Weekly downloads
 
Created
Source

next-tinacms-json

The next-tinacms-json package provides helpers to make local JSON content editable. This package is intended to be used with a Git-based workflow.

Installation

yarn add next-tinacms-json

API

ExportDescription
JsonFileA interface representing a JSON file stored on the local filesystem in Git.
useJsonFormReact Hook that creates a TinaCMS Form Plugin for editing a JsonFile.

JsonFile

The JsonFile interface represents a JSON file stored on the local filesystem in Git.

export interface JsonFile {
  fileRelativePath: string
  data: any
}
NameDescription
fileRelativePathThe path to the file relative to the root of the Git repository.
dataThe parsed data from the JSON file.

useJsonForm

The useJsonForm function is a React Hook creates a TinaCMS Form Plugin for editing a JsonFile.

import { Form, FormOptions } from "tinacms"

export function useJsonForm(
  jsonFile: JsonFile,
  options?: FormOptions
):[any, Form]

The useJsonForm hook accepts a JsonFile and an optional FormOptions object. It returns an array with containing the current values aand the Form.

Example: pages/index.js

import { usePlugin } from 'tinacms'
import { useJsonForm } from 'next-tinacms-json'

export default function Index({ jsonFile }) {
  // Create the Form
  const [homePage, homePageForm] = useJsonForm(jsonFile)

  // Register it with the CMS
  usePlugin(homePageForm)

  return <h1>{homePage.title}</h1>
}

export async function getStaticProps() {
  const content = await import(`../../content/index.json`)

  return {
    props: {
      jsonFile: {
        fileRelativePath: `/content/index.json`,
        data: content.default,
      },
    },
  }
}

FAQs

Package last updated on 10 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc