Enhancement: Reusing fields of other content types #446

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

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

Originally posted by itsjavi April 3, 2023
I have 2 content types that have a very similar structure: "Page" and "Article", and I'd like to combine the fields that these 2 content types have in common, to avoid repeating the configuration. Kind of an "inheritance" / merge.

...

### Discussed in https://github.com/estruyf/vscode-front-matter/discussions/559 <div type='discussions-op-text'> <sup>Originally posted by **itsjavi** April 3, 2023</sup> I have 2 content types that have a very similar structure: "Page" and "Article", and I'd like to combine the fields that these 2 content types have in common, to avoid repeating the configuration. Kind of an "inheritance" / merge. ... </div> <!-- github-sync-id:1653331205 -->
adam closed this issue 2026-10-05 02:47:50 +02:00
Author
Owner

I am thinking about the following configuration/setup to reuse the fields:

{
  "frontMatter.taxonomy.fieldGroups": [
    {
      "id": "GeneralFields",
      "fields": [
        {
          "title": "Title",
          "name": "title",
          "type": "string",
          "single": true
        },
        {
          "title": "Description",
          "name": "description",
          "type": "string"
        }
      ]
    }
  ],
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "pageBundle": false,
      "previewPath": "'blog'",
      "filePrefix": null,
      "fields": [
        {
          "name": "fieldCollection",
          "type": "fieldCollection",
          "fieldGroup": "GeneralFields"
        },
        {
          "title": "Publishing date",
          "name": "pubDate",
          "type": "datetime",
          "default": "{{now}}",
          "isPublishDate": true
        },
        {
          "title": "Content preview",
          "name": "heroImage",
          "type": "image",
          "isPreviewImage": true
        }
      ]
    }
  ]
}

Do you have any feedback on this @Fasani @itsjavi?

Edit: I think reusing the frontMatter.taxonomy.fieldGroups would be better. This setting allows you to set field groups for the new fieldCollection and block fields.

I am thinking about the following configuration/setup to reuse the fields: ```json { "frontMatter.taxonomy.fieldGroups": [ { "id": "GeneralFields", "fields": [ { "title": "Title", "name": "title", "type": "string", "single": true }, { "title": "Description", "name": "description", "type": "string" } ] } ], "frontMatter.taxonomy.contentTypes": [ { "name": "default", "pageBundle": false, "previewPath": "'blog'", "filePrefix": null, "fields": [ { "name": "fieldCollection", "type": "fieldCollection", "fieldGroup": "GeneralFields" }, { "title": "Publishing date", "name": "pubDate", "type": "datetime", "default": "{{now}}", "isPublishDate": true }, { "title": "Content preview", "name": "heroImage", "type": "image", "isPreviewImage": true } ] } ] } ``` Do you have any feedback on this @Fasani @itsjavi? *Edit*: I think reusing the `frontMatter.taxonomy.fieldGroups` would be better. This setting allows you to set field groups for the new `fieldCollection` and `block` fields. <!-- github-comment-id:1721320835 -->
Author
Owner

@estruyf that will be enough :) thanks!

@estruyf that will be enough :) thanks! <!-- github-comment-id:1721410075 -->
Author
Owner

Great, I have added this logic to the latest beta version. Please feel free to test it out and let me know how it works for you.

Great, I have added this logic to the latest beta version. Please feel free to test it out and let me know how it works for you. <!-- github-comment-id:1721518555 -->
Author
Owner

@estruyf I finally could test it and works as expected, thanks for adding this! <3

@estruyf I finally could test it and works as expected, thanks for adding this! <3 <!-- github-comment-id:1768946870 -->
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#446