fix: handle / prefix in source
#71
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

This PR adds support for
prefixinsourcefor collections, which fixes the problem reported in #56The way this is implemented is to add a new
idproperty toTreeItem, which allows the Studio app to rely on native IDs fromnuxt/content, without having to duplicate or match the logic for generating those IDs. As a neat side effect, this might bring some slight performance benefits as some operations in the file tree no longer have to iterate. Also this removes a bunch ofitems.collection![0]assertions, which is nice too.I think its noteworthy to say that
generateIdFromFsPathfromtree.tsstill remains as there are some collection decoupled operations that still benefit from the basic idea of the function, however for collection item operations, I think it should be avoided.The primary issue of generating the file path from the ID is also fixed by ensuring that the fixed part of the include pattern is not removed if the
prefixis/.Note: This is not yet an ideal solution as
//{collectionName}, so this might need to be collection type aware. As per the Nuxt Content documentation, only page collections take use of the prefix, see https://github.com/nuxt/content/blob/87a2530e01b012be993d40eac3b310fdf5190882/docs/content/docs/2.collections/3.sources.md?plain=1#L45