I have a resizable grid inside my page preview template when I’m moving its items it’s changing coordinates, I would like to save this coordinates to markdown. How can I make it?
Here is my preview component, where I have a callback onLayoutChange
and I’m trying to use inside it setIn
(not sure if it’s correct) to persist my changes
import React from 'react'
import PropTypes from 'prop-types'
import { BlogPostTemplate } from '../../templates/blog-post'
const BlogPostPreview = ({ entry, widgetFor }) => {
const images = entry.getIn(['data', 'featuredimage']);
const tags = entry.getIn(['data', 'tags'])
const onLayoutChange = (data) => {
entry.setIn(['data', 'tags'], data)
};
return (
<BlogPostTemplate
content={widgetFor('body')}
onLayoutChange={onLayoutChange}
featuredImages={images}
description={entry.getIn(['data', 'description'])}
title={entry.getIn(['data', 'title'])}
/>
This file has been truncated. show original
Here is my page template, where grid itself and layout generator
import React from 'react'
import PropTypes from 'prop-types'
import { kebabCase } from 'lodash'
import { Helmet } from 'react-helmet'
import { graphql, Link } from 'gatsby'
import Layout from '../components/Layout'
import Content, { HTMLContent } from '../components/Content'
import GridLayout from "react-grid-layout";
export const BlogPostTemplate = ({
content,
contentComponent,
description,
tags,
title,
helmet,
featuredImages,
onLayoutChange
}) => {
This file has been truncated. show original
Thanks
erez
October 22, 2020, 9:48am
2
Hi @passingby , preview templates are designed to consume data generated by the CMS and not to pass data back to the CMS.
You can:
Model the grid coordinates in your config.yml
(maybe using an object widget wrapping some number widgets).
Create a custom widget to set the grid coordinates.
Use CMS preSave
event to change the content:
Beta Features! | Netlify CMS | Open-Source Content Management System