Enhancement: Add support for allowing multiple asset locations - monorepo #435

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

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

Originally posted by louiss0 March 18, 2023
I have decided to talk about this as a feature idea because. I didn't think of the problem as an issue as in bug. But what I'm going to talk about is a restriction. As of today you are only allowed to use one assets folder. This is not good for people like me who use mono-repos.

frontmatter-public-folder-snip

Right now this is all I can do. If can could specify multiple files they would look like this.

frontmatter-asset-folders-snip

This is what I want to do. The benefit of this is that the key could be the name of the place where each asset is displayed. The value is the folder to use. This means that pictures and where they come from can be specified in a mono-repo. even outside of a mono-repo developers can organize where each set of images are in a folder.

### Discussed in https://github.com/estruyf/vscode-front-matter/discussions/542 <div type='discussions-op-text'> <sup>Originally posted by **louiss0** March 18, 2023</sup> I have decided to talk about this as a feature idea because. I didn't think of the problem as an issue as in bug. But what I'm going to talk about is a restriction. As of today you are only allowed to use one assets folder. This is not good for people like me who use mono-repos. ![frontmatter-public-folder-snip](https://user-images.githubusercontent.com/29028601/226142951-4a84e74f-0d7e-41f4-b1ef-e995a23b19c0.png) Right now this is all I can do. If can could specify multiple files they would look like this. ![frontmatter-asset-folders-snip](https://user-images.githubusercontent.com/29028601/226143002-43da6bfc-483b-41bc-9687-39cba96fbc77.png) This is what I want to do. The benefit of this is that the key could be the name of the place where each asset is displayed. The value is the folder to use. This means that pictures and where they come from can be specified in a mono-repo. even outside of a mono-repo developers can organize where each set of images are in a folder. </div> <!-- github-sync-id:1638922394 -->
adam closed this issue 2026-10-05 02:47:18 +02:00
Author
Owner

I wish I could do more to help but I don't know much about this extension. I hope you remember that the key is supposed to be used to tell Frontmatter CMS what folder to put the assets in.

I wish I could do more to help but I don't know much about this extension. I hope you remember that the key is supposed to be used to tell Frontmatter CMS what folder to put the assets in. <!-- github-comment-id:1482754244 -->
Author
Owner

Thinking about a new assetFolder property on the page folders setting:

image

Thinking about a new `assetFolder` property on the page folders setting: ![image](https://user-images.githubusercontent.com/2900833/227739492-e9b07d7b-fd93-47bc-8789-95992798cf5c.png) <!-- github-comment-id:1483913251 -->
Author
Owner

Thinking about a new assetFolder property on the page folders setting:

image

I'm sorry but the pageFolders thing is throwing me off. I think this is an attempt to make the folders configurtion more modular instead of global. Which works. If you are thinking about making a modular architecture this means that each page folder should be a new context. My suggestion would have made everything be a part of the global scope. I think I'll need a bigger comment to express what I mean. But the thing is how will this affect Frontmatter CMS as a whole?

> Thinking about a new `assetFolder` property on the page folders setting: > > ![image](https://user-images.githubusercontent.com/2900833/227739492-e9b07d7b-fd93-47bc-8789-95992798cf5c.png) I'm sorry but the `pageFolders` thing is throwing me off. I think this is an attempt to make the folders configurtion more modular instead of global. Which works. If you are thinking about making a modular architecture this means that each page folder should be a new context. My suggestion would have made everything be a part of the global scope. I think I'll need a bigger comment to express what I mean. But the thing is how will this affect Frontmatter CMS as a whole? <!-- github-comment-id:1483916663 -->
Author
Owner

I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content.

That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done.

Screenshot 2023-03-30 at 13 30 11

In my opinion, option 5 is the best of all.

It would look as follows:

{
  "frontMatter.content.publicFolder": [
    {
      "title": "blog-public",
      "path": "[[workspace]]/blog/public",
      "publicFolders": ["blog-page"]
    },
    {
      "title": "portfolio-public",
      "path": "[[workspace]]/portfolio/public",
      "publicFolders": ["portfolio-page"]
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "blog-page",
      "path": "[[workspace]]/blog/content",
      "excludeSubdir": true
    },
    {
      "title": "portfolio-page",
      "path": "[[workspace]]/portfolio/content"
    }
  ]
}
I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content. That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done. ![Screenshot 2023-03-30 at 13 30 11](https://user-images.githubusercontent.com/2900833/228823151-429f97b8-df3b-4d19-b30c-12e755ad00af.png) In my opinion, **option 5** is the best of all. It would look as follows: ```json { "frontMatter.content.publicFolder": [ { "title": "blog-public", "path": "[[workspace]]/blog/public", "publicFolders": ["blog-page"] }, { "title": "portfolio-public", "path": "[[workspace]]/portfolio/public", "publicFolders": ["portfolio-page"] } ], "frontMatter.content.pageFolders": [ { "title": "blog-page", "path": "[[workspace]]/blog/content", "excludeSubdir": true }, { "title": "portfolio-page", "path": "[[workspace]]/portfolio/content" } ] } ``` <!-- github-comment-id:1490147959 -->
Author
Owner

I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content.

That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done.

Screenshot 2023-03-30 at 13 30 11

In my opinion, option 5 is the best of all.

It would look as follows:

{
  "frontMatter.content.publicFolder": [
    {
      "title": "blog-public",
      "path": "[[workspace]]/blog/public",
      "publicFolders": ["blog-page"]
    },
    {
      "title": "portfolio-public",
      "path": "[[workspace]]/portfolio/public",
      "publicFolders": ["portfolio-page"]
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "blog-page",
      "path": "[[workspace]]/blog/content",
      "excludeSubdir": true
    },
    {
      "title": "portfolio-page",
      "path": "[[workspace]]/portfolio/content"
    }
  ]
}

OK, I'm wondering what software did you use to create that diagram?

> I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content. > > That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done. > > ![Screenshot 2023-03-30 at 13 30 11](https://user-images.githubusercontent.com/2900833/228823151-429f97b8-df3b-4d19-b30c-12e755ad00af.png) > > In my opinion, **option 5** is the best of all. > > It would look as follows: > > ```json > { > "frontMatter.content.publicFolder": [ > { > "title": "blog-public", > "path": "[[workspace]]/blog/public", > "publicFolders": ["blog-page"] > }, > { > "title": "portfolio-public", > "path": "[[workspace]]/portfolio/public", > "publicFolders": ["portfolio-page"] > } > ], > "frontMatter.content.pageFolders": [ > { > "title": "blog-page", > "path": "[[workspace]]/blog/content", > "excludeSubdir": true > }, > { > "title": "portfolio-page", > "path": "[[workspace]]/portfolio/content" > } > ] > } > ``` OK, I'm wondering what software did you use to create that diagram? <!-- github-comment-id:1490345568 -->
Author
Owner

OK, I'm wondering what software did you use to create that diagram?

Using Mindnode for this

> OK, I'm wondering what software did you use to create that diagram? Using **Mindnode** for this <!-- github-comment-id:1490347113 -->
Author
Owner

I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content.

That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done.

Screenshot 2023-03-30 at 13 30 11

In my opinion, option 5 is the best of all.

It would look as follows:

{
  "frontMatter.content.publicFolder": [
    {
      "title": "blog-public",
      "path": "[[workspace]]/blog/public",
      "publicFolders": ["blog-page"]
    },
    {
      "title": "portfolio-public",
      "path": "[[workspace]]/portfolio/public",
      "publicFolders": ["portfolio-page"]
    }
  ],
  "frontMatter.content.pageFolders": [
    {
      "title": "blog-page",
      "path": "[[workspace]]/blog/content",
      "excludeSubdir": true
    },
    {
      "title": "portfolio-page",
      "path": "[[workspace]]/portfolio/content"
    }
  ]
}

I think this code snippet represents the idea that different assets can map to different folders. This is ok but I think you meant pageFolders not publicFolder I'm wondering how it would be displayed in the UI. Would it be one folder containing multiple folders. What is the excludeSubdir thing about. Can you also tell me how the publicFolders key influences the UI.

> I understand you @louiss0, but it needs to fit into the whole system. The setting you propose would work nicely when using a mono-repository, but it won't work or is a lot trickier when using a single project and wanting to specify two asset locations. Which I believe might also be an option on sites with various types of content. > > That is why I want to make a change that would work for both a single and a mono-repo project. I have listed the options which can be done. > > ![Screenshot 2023-03-30 at 13 30 11](https://user-images.githubusercontent.com/2900833/228823151-429f97b8-df3b-4d19-b30c-12e755ad00af.png) > > In my opinion, **option 5** is the best of all. > > It would look as follows: > > ```json > { > "frontMatter.content.publicFolder": [ > { > "title": "blog-public", > "path": "[[workspace]]/blog/public", > "publicFolders": ["blog-page"] > }, > { > "title": "portfolio-public", > "path": "[[workspace]]/portfolio/public", > "publicFolders": ["portfolio-page"] > } > ], > "frontMatter.content.pageFolders": [ > { > "title": "blog-page", > "path": "[[workspace]]/blog/content", > "excludeSubdir": true > }, > { > "title": "portfolio-page", > "path": "[[workspace]]/portfolio/content" > } > ] > } > ``` I think this code snippet represents the idea that different assets can map to different folders. This is ok but I think you meant `pageFolders` not `publicFolder` I'm wondering how it would be displayed in the **UI**. Would it be one folder containing multiple folders. What is the `excludeSubdir` thing about. Can you also tell me how the `publicFolders` key influences the UI. <!-- github-comment-id:1490428656 -->
Author
Owner

Have been trying option number 5 and 4. Option 5 is a huge change in architecture, but also leads to confusion on how to highlight the correct folder when you open a file.

Option 4 might be easier for users to understand and the implementation/configuration is pretty easy. The frontMatter.projects setting, allows you to override any of the global defined settings. So in your case, you can define the page folders and public/asset folders per project. Once that is done, on the dashboard and panel you'll be able two switch between the projects.

https://user-images.githubusercontent.com/2900833/228933325-c524dd55-ae9e-454f-a7b5-89c9a3d52ac4.mov

{
  "frontMatter.projects": [{
    "name": "eliostruyf.com",
    "default": true,
    "configuration": {
      "frontMatter.content.pageFolders": [
        {
          "title": "Blog posts",
          "path": "[[workspace]]/.frontmatter/content/posts"
        }
      ],
      "frontMatter.content.publicFolder": ".frontmatter/static/uploads"
    }
  }, {
    "name": "elio.dev",
    "configuration": {
      "frontMatter.content.pageFolders": [
        {
          "title": "Portfolio",
          "path": "[[workspace]]/.frontmatter/content/projects"
        }
      ],
      "frontMatter.content.publicFolder": ".frontmatter/static/social"
    }
  }]
}
Have been trying option number 5 and 4. Option 5 is a huge change in architecture, but also leads to confusion on how to highlight the correct folder when you open a file. Option 4 might be easier for users to understand and the implementation/configuration is pretty easy. The `frontMatter.projects` setting, allows you to override any of the global defined settings. So in your case, you can define the page folders and public/asset folders per project. Once that is done, on the dashboard and panel you'll be able two switch between the projects. https://user-images.githubusercontent.com/2900833/228933325-c524dd55-ae9e-454f-a7b5-89c9a3d52ac4.mov ```json { "frontMatter.projects": [{ "name": "eliostruyf.com", "default": true, "configuration": { "frontMatter.content.pageFolders": [ { "title": "Blog posts", "path": "[[workspace]]/.frontmatter/content/posts" } ], "frontMatter.content.publicFolder": ".frontmatter/static/uploads" } }, { "name": "elio.dev", "configuration": { "frontMatter.content.pageFolders": [ { "title": "Portfolio", "path": "[[workspace]]/.frontmatter/content/projects" } ], "frontMatter.content.publicFolder": ".frontmatter/static/social" } }] } ``` <!-- github-comment-id:1490759988 -->
Author
Owner

Have been trying option number 5 and 4. Option 5 is a huge change in architecture, but also leads to confusion on how to highlight the correct folder when you open a file.

Option 4 might be easier for users to understand and the implementation/configuration is pretty easy. The frontMatter.projects setting, allows you to override any of the global defined settings. So in your case, you can define the page folders and public/asset folders per project. Once that is done, on the dashboard and panel you'll be able two switch between the projects.

{
  "frontMatter.projects": [{
    "name": "eliostruyf.com",
    "default": true,
    "configuration": {
      "frontMatter.content.pageFolders": [
        {
          "title": "Blog posts",
          "path": "[[workspace]]/.frontmatter/content/posts"
        }
      ],
      "frontMatter.content.publicFolder": ".frontmatter/static/uploads"
    }
  }, {
    "name": "elio.dev",
    "configuration": {
      "frontMatter.content.pageFolders": [
        {
          "title": "Portfolio",
          "path": "[[workspace]]/.frontmatter/content/projects"
        }
      ],
      "frontMatter.content.publicFolder": ".frontmatter/static/social"
    }
  }]
}

How have you been testing this out? You can use the Frontmatter CMS repo to test things out. I think I like Option 4. I'm biased because I'm new to this library. But I think this option allows devs to be very explicit about which project each assets are associated with. I also think this removes the boilerplate introduced by Option 5. I don't know how dangerous it is to do Option 4 because I don't know how long it has been around. But If this project is young I'd suggest you go for Option 4.

I know the architectural changes are not easy but they are good if they simplify things or add much-needed flexibility.

> Have been trying option number 5 and 4. Option 5 is a huge change in architecture, but also leads to confusion on how to highlight the correct folder when you open a file. > > Option 4 might be easier for users to understand and the implementation/configuration is pretty easy. The `frontMatter.projects` setting, allows you to override any of the global defined settings. So in your case, you can define the page folders and public/asset folders per project. Once that is done, on the dashboard and panel you'll be able two switch between the projects. > > ```json > { > "frontMatter.projects": [{ > "name": "eliostruyf.com", > "default": true, > "configuration": { > "frontMatter.content.pageFolders": [ > { > "title": "Blog posts", > "path": "[[workspace]]/.frontmatter/content/posts" > } > ], > "frontMatter.content.publicFolder": ".frontmatter/static/uploads" > } > }, { > "name": "elio.dev", > "configuration": { > "frontMatter.content.pageFolders": [ > { > "title": "Portfolio", > "path": "[[workspace]]/.frontmatter/content/projects" > } > ], > "frontMatter.content.publicFolder": ".frontmatter/static/social" > } > }] > } > ``` How have you been testing this out? You can use the Frontmatter CMS repo to test things out. I think I like Option 4. I'm biased because I'm new to this library. But I think this option allows devs to be very explicit about which project each assets are associated with. I also think this removes the boilerplate introduced by Option 5. I don't know how dangerous it is to do Option 4 because I don't know how long it has been around. But If this project is young I'd suggest you go for Option 4. I know the architectural changes are not easy but they are good if they simplify things or add much-needed flexibility. <!-- github-comment-id:1490908538 -->
Author
Owner

I have been testing it out against my blog and some of the sample sites: https://github.com/FrontMatter/project-samples

Option 4 will be the easiest to understand and allows the most flexibility for future implementations.

The implementation isn't that "dangerous"; without any projects defined, it will be as it is right now.

I have been testing it out against my blog and some of the sample sites: https://github.com/FrontMatter/project-samples Option 4 will be the easiest to understand and allows the most flexibility for future implementations. The implementation isn't that "dangerous"; without any projects defined, it will be as it is right now. <!-- github-comment-id:1491387108 -->
Author
Owner

It has been pushed to the latest beta version and can be tested by adding a similar configuration as shown above.

It has been pushed to the latest beta version and can be tested by adding a similar configuration as shown above. <!-- github-comment-id:1491471318 -->
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#435