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: A single multilingual pageFolder is now getting replaced by one per language in frontmatter.json. #769

Closed
tohagan opened this issue Mar 1, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@tohagan
Copy link

tohagan commented Mar 1, 2024

Describe the bug

In frontmatter.json, it looks like the original simple model for i18n and pageFolder is getting transformed internally and then (perhaps unintentionally?) getting persisted to back to frontmatter.json.

IMHO, this complicates and duplicates information in the frontmatter.json model. Is that what you intended??
Perhaps you need to maintain a computed pageFolder model that maintains the original model as isomorphic in this aspect.

Example

frontmatter.json

...
  "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"
      ]
    }

  ],

... is getting converted into this that's saved in the ...

  "frontMatter.content.pageFolders": [
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ],
      "locale": "en",
      "localeTitle": "English",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/posts"
    },
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/hi",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ],
      "locale": "hi",
      "localeTitle": "Hindi",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/posts"
    },
    {
      "title": "posts",
      "path": "[[workspace]]/src/content/posts/bn",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "post"
      ],
      "locale": "bn",
      "localeTitle": "Bengali",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/posts"
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site/en",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ],
      "locale": "en",
      "localeTitle": "English",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/site"
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site/hi",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ],
      "locale": "hi",
      "localeTitle": "Hindi",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/site"
    },
    {
      "title": "site",
      "path": "[[workspace]]/src/content/site/bn",
      "filePrefix": "",
      "defaultLocale": "en",
      "contentTypes": [
        "site"
      ],
      "locale": "bn",
      "localeTitle": "Bengali",
      "localeSourcePath": "c:/Users/tony/Projects/JOI-Software/SGY_SITE/site/src/content/site"
    },
]
@tohagan tohagan added the bug Something isn't working label Mar 1, 2024
estruyf added a commit that referenced this issue Mar 1, 2024
@estruyf
Copy link
Owner

estruyf commented Mar 1, 2024

The settings update was overlooked. Those fields are internal and shouldn't be pushed to the configuration file, and an update to fix it has been pushed. It should be available in the latest beta. Let me know if it got fixed, and I'll release it to the stable version.

@estruyf
Copy link
Owner

estruyf commented Mar 1, 2024

BETA Version: 10.0.8108301

@tohagan
Copy link
Author

tohagan commented Mar 1, 2024

Tested and passed. I added a temporary snippet to ensure frontmatter.json was serialised and the result was ok.
Thanks again. Glad we caught this one before it broke too many frontmatter.json files in the wild.

@tohagan tohagan closed this as completed Mar 1, 2024
@tohagan
Copy link
Author

tohagan commented Mar 1, 2024

Release notes might want to have repair instructions.

@estruyf estruyf mentioned this issue Mar 1, 2024
estruyf added a commit that referenced this issue Mar 1, 2024
@estruyf
Copy link
Owner

estruyf commented Mar 1, 2024

@tohagan a fix will be included to revert the setting to the original state:

if (major === 10 && minor === 0 && patch < 2) {
let folders = Settings.get<ContentFolder[]>(SETTING_CONTENT_PAGE_FOLDERS) || [];
folders = folders
.filter((f) => !f.locale || f.locale === f.defaultLocale)
.map((f) => {
delete f.locale;
delete f.localeTitle;
if (f.localeSourcePath) {
const wsFolder = Folders.getWorkspaceFolder();
if (wsFolder) {
const localPath = parseWinPath(f.localeSourcePath).replace(
parseWinPath(wsFolder.fsPath),
WORKSPACE_PLACEHOLDER
);
f.path = localPath;
}
delete f.localeSourcePath;
}
return f;
});
await Settings.update(SETTING_CONTENT_PAGE_FOLDERS, folders, true);
}

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