decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.66k stars 3.02k forks source link

Unable to create custom formatter: TypeError: r.getIn is not a function #7109

Open caendesilva opened 4 months ago

caendesilva commented 4 months ago

Describe the bug Following the documentation I'm trying to create a custom formatter to read and write the page source as plaintext.

To Reproduce

Add the following:

CMS.registerCustomFormat('blade', '.blade.php', {
  fromFile: text => text,
  toFile: value => value,
});

The admin panel breaks.

Expected behavior

The admin panel should work.

Screenshots

image

Applicable Versions:

CMS configuration

backend:
  name: github
  repo: hyde-staging/decap-test
site_url: https://hyde-staging.github.io/decap-test
logo_url: /admin/assets/logo.svg
media_folder: _media
public_folder: media
commit_messages:
  create: Create {{collection}} "{{slug}}" from Decap
  update: Update {{collection}} "{{slug}}" from Decap
  delete: Delete {{collection}} "{{slug}}" from Decap
  uploadMedia: Upload "{{path}}" from Decap
  deleteMedia: Delete "{{path}}" from Decap
  openAuthoring: "{{message}}"
collections:
  - name: posts
    label: Blog Posts
    label_singular: Post
    description: The blog posts for the site
    folder: _posts
    create: true
    slug: "{{slug}}"
    preview_path: posts/{{slug}}
    fields:
      - label: Title
        name: title
        widget: string
      - label: Cover Image
        name: image
        widget: image
      - label: Description
        name: Description
        widget: string
      - label: Category
        name: category
        widget: string
      - label: Date
        name: date
        widget: datetime
      - label: Author
        name: author
        widget: string
      - label: Body
        name: body
        widget: markdown
    publish: true
    type: folder_based_collection
    sortable_fields:
      - commit_date
      - title
      - date
      - author
    view_filters: []
    view_groups: []
  - name: docs
    label: Documentation Pages
    label_singular: Documentation Page
    description: The documentation pages for the site
    folder: _docs
    create: true
    slug: "{{slug}}"
    preview_path: docs/{{slug}}
    fields:
      - label: Title
        name: title
        widget: string
      - label: Body
        name: body
        widget: markdown
    publish: true
    type: folder_based_collection
    sortable_fields:
      - commit_date
      - title
      - commit_author
    view_filters: []
    view_groups: []
  - name: markdown-pages
    label: Markdown Pages
    label_singular: Markdown Page
    description: The Markdown pages for the site
    folder: _pages
    create: true
    slug: "{{slug}}"
    preview_path: "{{slug}}"
    fields:
      - label: Title
        name: title
        widget: string
      - label: Body
        name: body
        widget: markdown
    publish: true
    type: folder_based_collection
    sortable_fields:
      - commit_date
      - title
      - commit_author
    view_filters: []
    view_groups: []
  - name: blade-pages
    label: Blade Pages
    label_singular: Blade Page
    description: The Blade pages for the site
    folder: _pages
    extension: .blade.php
    format: blade
    create: true
    slug: "{{slug}}"
    preview_path: "{{slug}}"
    fields:
      - label: Title
        name: title
        widget: string
      - label: Blade
        name: body
        widget: text
    editor:
      preview: false
    publish: true
    type: folder_based_collection
    sortable_fields:
      - commit_date
      - title
      - commit_author
    view_filters: []
    view_groups: []
publish_mode: simple
slug:
  encoding: unicode
  clean_accents: false
  sanitize_replacement: "-"
display_url: https://hyde-staging.github.io/decap-test
isFetching: false
error: null

Additional context