Enhancement: New content-relationship field? #460

Closed
opened 2026-10-05 02:48:29 +02:00 by adam · 4 comments
Owner

Discussed in https://github.com/estruyf/vscode-front-matter/discussions/583

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

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

### Discussed in https://github.com/estruyf/vscode-front-matter/discussions/583 <div type='discussions-op-text'> <sup>Originally posted by **adrian-ub** May 9, 2023</sup> Relationship like Netlify CMS https://decapcms.org/docs/widgets/relation/</div> <!-- github-sync-id:1702573945 -->
adam closed this issue 2026-10-05 02:48:29 +02:00
Author
Owner

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.

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: ```json "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. <!-- github-comment-id:1551808744 -->
Author
Owner

Screenshot 2023-05-17 at 19 39 19

![Screenshot 2023-05-17 at 19 39 19](https://github.com/estruyf/vscode-front-matter/assets/2900833/cda7356f-89d1-446c-ba39-a3598b05c9bd) <!-- github-comment-id:1551811230 -->
Author
Owner

@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 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: <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/a1ac03b9-64f6-4ec1-a371-61e09043de0f"> Content without field slug <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/e0c09ae8-d2e3-431c-b9b6-9440af01442a"> <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/60a7ee45-ed88-4678-aecf-39c41799ad0f"> With field slug: <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/b09cfe67-fd14-4ad0-bfa0-0e665c0a4a22"> <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/d49280d4-b81b-4d02-8a76-930c0acee058"> Example: https://github.com/adrian-ub/experiment-relationship-fronmatter try to do it with pageBundle, but it gets me information from another contentType <img width="2032" alt="image" src="https://github.com/estruyf/vscode-front-matter/assets/22903142/a28f0fbf-e9e3-445d-9db1-b08811bf6b51"> Example: https://github.com/adrian-ub/site-content <!-- github-comment-id:1555419997 -->
Author
Owner

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.

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. <!-- github-comment-id:1559539493 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#460