estruyf / vscode-front-matter

Front Matter is a CMS running straight in Visual Studio Code. Can be used with static site generators like Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...
https://frontmatter.codes
MIT License
1.95k stars 77 forks source link

Issue: FM Beta: Dashboard multilingual feature issues #760

Closed tohagan closed 7 months ago

tohagan commented 7 months ago

Describe the bug

I've had a chance to give the new beta version a workout and found a few issues that I've listed below as a group. You might prefer they be logged as separate issues.

Here's the relevant part of my fontmatter.json file:

"frontMatter.content.i18n": [
    {
      "title": "English",
      "locale": "en"
    },
    {
      "title": "Hindi",
      "locale": "hi",
      "path": "../hi"
    },
    {
      "title": "Bengali",
      "locale": "bn",
      "path": "../bn"
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ]
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ]
    }
  ],
  1. https://frontmatter.codes/frontmatter.schema.json - Missing schema item for "defaultLocale"

image

  1. In the Dashboard, combining filtering of locale with content type returns an empty list if the local is not English.

To Reproduce + Expected behavior

  1. Locale filter sometimes disappears.

I haven't yet found a reproducible steps for this bug but I've seen it multiple times now. I suspect what's going is that the condition to display this filter option is in some way related to the list of documents found rather than the existence of the "frontMatter.content.i18n" setting.

Desktop (please complete the following information):

estruyf commented 7 months ago
  1. It Is not an issue; it is because the feature is in beta and not yet available on the main JSON schema. If you change the schema to: https://beta.frontmatter.codes/frontmatter.schema.json, it fixes it.
  2. I'll take a look into it.
estruyf commented 7 months ago

@tohagan can you verify if the latest beta fixed issue 2?

Still looking into 3.

estruyf commented 7 months ago

I was able to reproduce it once. Changed the logic of the filter a bit, and should now be kept visible.

tohagan commented 7 months ago

The Content types list is now showing a mixture of content type + language, whereas I think it should just be the content type (post/site) since the language should be selected by just the language filter. I will eventually have lots more languages and potentially more content types so this list would get out of hand if it had all combinations.

image

I'm also now not seeing English in the Languages list

image

tohagan commented 7 months ago
  1. https://beta.frontmatter.codes/frontmatter.schema.json

Cool ... was just confirming that you'd not missed this schema change.

estruyf commented 7 months ago

@tohagan I'll change the logic in the Type filter. There it doesn't make sense.

Btw, does the English label ever show up in the language dropdown?

estruyf commented 7 months ago

Fixed the types filter, now it should only show you posts and site.

Any idea how I can reproduce the locale filter?

Can you do a screen recording of it?

estruyf commented 7 months ago

@tohagan changed the locale retrieval logic a bit for the filter.

tohagan commented 7 months ago

Yeah that's fixed the Locale list. Well done!

Filtering is now better as I can now filter by Language + Content type for 2 of my 3 languages. However, when I select English I'm seeing NO documents in the list. This happens whether or not a Content type is selected.

I've tested this with a couple of different configurations. For each configuration change, I used ... (a) the refresh button image (b) Restarting VSCode

"frontMatter.content.i18n": [
    {
      "title": "English",
      "locale": "en",
      "path": "."
    },
    {
      "title": "Hindi",
      "locale": "hi",
      "path": "../hi"
    },
    {
      "title": "Bengali",
      "locale": "bn",
      "path": "../bn"
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ]
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ]
    }
  ],

And also this configuration that IMHO is the most logical to use. The other one will just confuse people.

 "frontMatter.content.i18n": [
    {
      "title": "English",
      "locale": "en",
      "path": "en"
    },
    {
      "title": "Hindi",
      "locale": "hi",
      "path": "hi"
    },
    {
      "title": "Bengali",
      "locale": "bn",
      "path": "bn"
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ]
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ]
    }
  ],
tohagan commented 7 months ago

In the LHS panel, the group headings should show Content Type + Locale but currently only show Content Type:

image

tohagan commented 7 months ago

If you'd like to do a joint Zoom session to speed up your testing/fixing cycle. I'd be available today. Your time zone is 9 hours behind me. I have Zoom Pro if needed. Check my profile for email address.

tohagan commented 7 months ago

Sent you an email so check Spam if you can't see it.

estruyf commented 7 months ago

Thanks, @tohagan; I believe I had enough with the provided configuration. Found the issue on my Windows device, it was related to the file path matching.

Implemented a fix and tested it on my Windows device, now the multilingual content is shown correctly, filters are working and content creation as well.

tohagan commented 7 months ago

I think all issues are now fixed. Thank you @estruyf . Greatly appreciated and I think this will be a valued addition for many users.

estruyf commented 7 months ago

Thanks @tohagan for testing and also for becoming a sponsor 🙏