Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to extend netlifyCMS with CMS.registerWidget? #9

Open
preetamslot opened this issue Jun 24, 2022 · 4 comments
Open

How to extend netlifyCMS with CMS.registerWidget? #9

preetamslot opened this issue Jun 24, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@preetamslot
Copy link
Contributor

Hi,
Where is the place to add custom widgets for netlify CMS to extend the cms?
thanks

@delucis
Copy link
Owner

delucis commented Jun 24, 2022

Hi @preetamslot!

It's currently not supported. My plan is to offer config options that the integration would read and then call registerWidget for you, but haven't had a chance to do that yet.

So the config would look something like:

NetlifyCMS({
  config: { ... },
  widgets: [
    {
      name: 'my-widget',
      control: <PATH TO REACT COMPONENT>,
    }
  ],
})

@delucis delucis reopened this Jul 4, 2022
@delucis
Copy link
Owner

delucis commented Jul 4, 2022

Reopening this to keep as a reminder that we do want to support this!

@codelastnight
Copy link
Contributor

It would also be cool to support CMS.registerMediaLibrary(), probably with the same pattern as widget

@delucis delucis added the enhancement New feature or request label Oct 22, 2022
@tomashco
Copy link

Hi there,
regarding the mdx support, I did some testing and made somehow to register the mdx widget inside the editor editing these files:
vite-plugin-admin-dashboard.ts:

return `${imports.join('\n')}
    import * as NCMS from 'netlify-cms-app';
    import { MdxControl, MdxPreview } from 'netlify-cms-widget-mdx';
    NCMS.registerWidget('mdx', MdxControl, MdxPreview);

    ${identityWidget}
    export default {
      cms: NCMS,
      config: JSON.parse('${JSON.stringify(config)}'),
      previewStyles: [${styles.join(',')}],
    }`

and inside the collection of the posts in the NetlifyCMS config I added:
`extension: 'mdx',
format: 'frontmatter',
fields:

This setup allows you to edit a mdx file, but I've found two problems:

  • the preview panel displays an error when I try to add mdx content:
    Invalid MDX:
    ReferenceError: process is not defined

  • I'm not able to visualize the mdx content created into astro (i.e. trying to view the blog post created)

Hope this can help to further understand and implement mdx in netlify cms!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants