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

Issue: Workspace settings.json duplicates user settings.json #133

Closed
flikteoh opened this issue Oct 5, 2021 · 11 comments
Closed

Issue: Workspace settings.json duplicates user settings.json #133

flikteoh opened this issue Oct 5, 2021 · 11 comments
Labels
bug Something isn't working
Milestone

Comments

@flikteoh
Copy link

flikteoh commented Oct 5, 2021

Describe the bug

I created a custom content types via user settings.json (user settings).

On every launch of vscode, the plugin creates .vscode/settings.json (workspace settings) merging custom content type + custom description fields and lastmod field.

This causes duplicated fields on every relaunches. (on every launch of vscode, same fields are added to the workspace settings)

Note the lowercased updated and summary are the custom Modified Field and Description field set in user settings.

screen 7

To Reproduce
Steps to reproduce the behavior:

Step 1: In user settings.json

  "frontMatter.taxonomy.seoDescriptionLength": 180,
  "frontMatter.taxonomy.modifiedField": "updated",
  "frontMatter.taxonomy.seoDescriptionField": "summary",
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "fields": [
        {
          "title": "Published",
          "name": "date",
          "type": "datetime"
        },
        {
          "title": "Updated",
          "name": "updated",
          "type": "datetime"
        }
      ]
    }
  ],

Step 2: Close and relaunch vscode

Step 3: .vscode/settings.json (workspace settings)

{
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "default",
      "fields": [
        {
          "title": "Published",
          "name": "date",
          "type": "datetime"
        },
        {
          "title": "Updated",
          "name": "updated",
          "type": "datetime"
        },
        {
          "name": "updated",
          "type": "datetime"
        },
        {
          "name": "summary",
          "type": "string"
        },
        {
          "name": "updated",
          "type": "datetime"
        },
        {
          "name": "summary",
          "type": "string"
        }
      ]
    }
  ]
}

This file will keep adding same fields on every vscode relaunch.

Expected behavior

Make workspace settings as optional / unify to one settings file?

@flikteoh flikteoh changed the title Issue: Workspace settings.json overrides user settings.json Issue: Workspace settings.json duplicates user settings.json Oct 5, 2021
@estruyf estruyf added the bug Something isn't working label Oct 5, 2021
@estruyf
Copy link
Owner

estruyf commented Oct 5, 2021

@flikteoh thanks for opening the issue. I'll investigate this and try to fix it.

@estruyf
Copy link
Owner

estruyf commented Oct 5, 2021

The issue is fixed in the beta version. In your case, it will only add the missing summary field, but it will not touch the updated field.

Since version 4, the global settings frontmatter.json file got introduced. It makes it easier to share settings with others, as not everyone shares their settings.json file with others. Related to this, I have added a prompt (one time) that asks if you wish to promote your local settings to the frontmatter.json file. This was already in place but required manual action.

Screenshot 2021-10-05 at 13 21 10

@estruyf estruyf added this to the 5.0.0 milestone Oct 5, 2021
@flikteoh
Copy link
Author

flikteoh commented Oct 5, 2021

The issue is fixed in the beta version. In your case, it will only add the missing summary field, but it will not touch the updated field.

Since version 4, the global settings frontmatter.json file got introduced. It makes it easier to share settings with others, as not everyone shares their settings.json file with others. Related to this, I have added a prompt (one time) that asks if you wish to promote your local settings to the frontmatter.json file. This was already in place but required manual action.

Screenshot 2021-10-05 at 13 21 10

Does this mean we can copy the config from user settings.json into frontmatter.json to have the panel showing only date and updated?

@flikteoh
Copy link
Author

flikteoh commented Oct 6, 2021

Hi @estruyf thanks for your prompt respond to the issue.

I have tried out the beta version. It does stop duplicating updated field.

However, summary continues to show up on Front Matter panel.

Is there no way to make plugin prioritize user settings.json on contentTypes since if user explicitly set it to exclude a particular field?

For use case like the description/summary field, it feels a bit redundant to be there since it can be easier to edit/manage on the writing panel itself.

I get a little confused on whether we should be configuring settings via .vscode/settings.json or user/settings.json or frontmatter.json ?

On the side, also found some error:

screen 4

Thank you

@estruyf
Copy link
Owner

estruyf commented Oct 6, 2021

Thanks @flikteoh for testing this out.

About the summary field that it keeps popping up, this is because you specified to use summary for the SEO description. The default content type is using description that is why it gets replaced to what you are using. We could add a property on the field to specify if it is hidden, but something else you could do, is specify your own content type. As you are now using the default one, you could also using your own. This is something Front Matter will not touch.

In order for the extension to progress, it will focus on using the frontmatter.json file as the main configuration. Overriding settings on user level will still be possible. Anything that is defined on the global file, can be overwritten in the local settings.json configuration.

For the schema, I'll try to find out why this might occur, as the file is available.

@estruyf
Copy link
Owner

estruyf commented Oct 6, 2021

The schema seems to be an issue in VS Code itself, there is an open issue on this. On the insiders version, this is already fixed it seems. I'll keep the issue open to follow it up.

@flikteoh
Copy link
Author

flikteoh commented Oct 6, 2021

Thank you @estruyf

I have finally figured out what are the right way to move the configs to frontmatter.json

Everything seems to work as we needed now.

Was is a plugin requirement to have these files scattered around root folder, .vscode, .templates, .frontmatter?

Or can they all be collected under one single folder for easier management? ie: .frontmatter/templates .frontmatter/settings.json,.frontmatter/frontmatter.json etc?

@estruyf
Copy link
Owner

estruyf commented Oct 6, 2021

It wasn't a plugin requirement to scatter files around. .vscode is the default way, but this is more on a personal level. That is why the frontmatter.json file was created. Not every project is a personal project, and not every project shares its .vscode folder.

On the .templates and .frontmatter folder, I understand that they could be combined. In the case of .templates, this can already be achieved by updating the frontmatter.templates.folder setting.

The frontmatter.json is currently expected on the root. It is also used for finding out the main project folder when using multi-folder workspace in VSCode.

@flikteoh
Copy link
Author

flikteoh commented Oct 6, 2021

It wasn't a plugin requirement to scatter files around. .vscode is the default way, but this is more on a personal level. That is why the frontmatter.json file was created. Not every project is a personal project, and not every project shares its .vscode folder.

On the .templates and .frontmatter folder, I understand that they could be combined. In the case of .templates, this can already be achieved by updating the frontmatter.templates.folder setting.

The frontmatter.json is currently expected on the root. It is also used for finding out the main project folder when using multi-folder workspace in VSCode.

That's understandable. Thanks for clarifying!

My issue is resolved. Do close this when you think it is ok.

@estruyf
Copy link
Owner

estruyf commented Oct 6, 2021

Thanks for your feedback! Appreciated to think with me on this one. I'll close it once the new version got released.

@estruyf
Copy link
Owner

estruyf commented Oct 6, 2021

@flikteoh thank you for becoming a sponsor! 🙏 I just added you to the readme + website as one of the sponsors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants