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

Enhancement: New content-relationship field? #585

Closed
estruyf opened this issue May 9, 2023 Discussed in #583 · 4 comments
Closed

Enhancement: New content-relationship field? #585

estruyf opened this issue May 9, 2023 Discussed in #583 · 4 comments

Comments

@estruyf
Copy link
Owner

estruyf commented May 9, 2023

Discussed in #583

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

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

@estruyf
Copy link
Owner Author

estruyf commented May 17, 2023

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.

@estruyf
Copy link
Owner Author

estruyf commented May 17, 2023

Screenshot 2023-05-17 at 19 39 19

@adrian-ub
Copy link

@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

estruyf added a commit that referenced this issue May 23, 2023
@estruyf
Copy link
Owner Author

estruyf commented May 23, 2023

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
Projects
None yet
Development

No branches or pull requests

2 participants