import "../styles.css" ; import dynamic from "next/dynamic" ; import { TinaEditProvider } from "tinacms/dist/edit-state" ; import { Layout } from "../components/layout" ; import { RouteMappingPlugin } from "tinacms" ; const TinaCMS = dynamic ( ( ) => import ( "tinacms" ) , { ssr : false } ) ; const App = ( { Component , pageProps } ) => { return ( < > < TinaEditProvider showEditButton = { true } editMode = { < TinaCMS apiURL = { process . env . NEXT_PUBLIC_TINA_API_URL } mediaStore = { async ( ) => { const pack = await import ( "next-tinacms-cloudinary" ) ; return pack . TinaCloudCloudinaryMediaStore ; } } cmsCallback = { ( cms ) => { import ( "react-tinacms-editor" ) . then ( ( { MarkdownFieldPlugin } ) => { cms . plugins . add ( MarkdownFieldPlugin ) ; } ) ; cms . flags . set ( "branch-switcher" , true ) ; /**
                 * Enables `tina-admin` specific features in the Tina Sidebar
                 */ cms . flags . set ( "tina-admin" , false ) ; /**
                 * An example of a RouteMapping plugin for TinaAdmin
                 */ const RouteMapping = new RouteMappingPlugin ( ( collection , document ) => { if ( [ "authors" , "global" ] . includes ( collection . name ) ) { return undefined ; } if ( [ "pages" ] . includes ( collection . name ) ) { if ( document . sys . filename === "home" ) { return `/` ; } if ( document . sys . filename === "about" ) { return `/about` ; } return undefined ; } return `/${ collection . name }/${ document . sys . filename }` ; } ) ; cms . plugins . add ( RouteMapping ) ; } } documentCreatorCallback = { { /**
                 * After a new document is created, redirect to its location
                 */ onNewDocument : ( { collection : { slug } , breadcrumbs } ) => { const relativeUrl = `/${ slug }/${ breadcrumbs . join ( "/" ) }` ; return ( window . location . href = relativeUrl ) ; } , filterCollections : ( options ) => { return options . filter ( ( option ) => option . label === "Blog Posts" ) ; } , } } formifyCallback = { ( { formConfig , createForm , createGlobalForm } ) => { if ( formConfig . id === "getGlobalDocument" ) { return createGlobalForm ( formConfig , { layout : "fullscreen" } ) ; } return createForm ( formConfig ) ; } } { ... pageProps } > { ( livePageProps ) => ( < Layout rawData = { livePageProps } data = { livePageProps . data ?. getGlobalDocument ?. data } > < Component { ... livePageProps } / > < /Layout>)} < /TinaCMS>}> < Layout rawData = { pageProps } data = { pageProps . data ?. getGlobalDocument ?. data } > < Component { ... pageProps } / > < /Layout> < /TinaEditProvider> < />); } ; export default App ;