Skip to content

Enhancement: New content-relationship field? #585

Closed

Description

@estruyf

Discussed in #583

Originally posted by adrian-ub May 9, 2023
Relationship like Netlify CMS

https://decapcms.org/docs/widgets/relation/

Activity

  1. added a commit that references this issue on May 17, 2023
  2. estruyf commented on May 17, 2023

    @estruyf
    OwnerAuthor

    The implementation of this new content relationship field has been added to the latest beta version.

    To use it, you can use the following configuration:

    "frontMatter.taxonomy.contentTypes": [
    {
          "name": "project",
          "pageBundle": false,
          "fields": [
            {
              "title": "Title",
              "name": "title",
              "type": "string",
              "required": true
            },
            {
              "title": "Session",
              "name": "session",
              "type": "contentRelationship", // This is the new field type
              "contentTypeName": "session", // Name of the content-type to link
              "contentTypeValue": "slug", // The type of link/value you want to add. This can be slug, or path. 
              "required": true
            },
            {
              "title": "Session path",
              "name": "sessionPath",
              "type": "contentRelationship",
              "contentTypeName": "session",
              "contentTypeValue": "path",
              "required": true
            }
          ]
        }
    ]

    @adrian-ub, feel free to give it a try.

  3. estruyf commented on May 17, 2023

    @estruyf
    OwnerAuthor

    Screenshot 2023-05-17 at 19 39 19

  4. adrian-ub commented on May 20, 2023

    @adrian-ub

    @estruyf thanks for the early development, I have tested the implementation, it works correctly when the slug en property is set in the content

    configuration in json file:

    image

    Content without field slug

    image image

    With field slug:

    image image

    Example: https://github.com/adrian-ub/experiment-relationship-fronmatter

    try to do it with pageBundle, but it gets me information from another contentType

    image

    Example: https://github.com/adrian-ub/site-content

  5. added a commit that references this issue on May 23, 2023
  6. estruyf commented on May 23, 2023

    @estruyf
    OwnerAuthor

    I just did a minor fix to generate the slugs only in memory. That way, it will not get the undefined value.

    To use it, first run the Front Matter: Clear cache command; once you run that, it will reinitialize the cache and the issue should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions