Open techfg opened 7 months ago
This is actually a really good idea! I really like "Option 1" as an opt-in. Let me get through the other PRs/Issues that you've created to enable this
@techfg just coming back to this. I think this is really a good idea and creates a lot of flexibility (yeah, repeat of the comment back in April ha)
I'm a bit confused though as to the order in which you see things getting merged (too many issues / prs floating around haha - it's a good thing). I think I'm understanding, but just want to confirm.
Hi @vernak2539 -
Sorry for the confusion. Technically speaking #50 contains everything in #49 and therefore #49 could be closed and only #50 merged.
That said, the PRs to deviate a little in terms of commits beyond a certain point (where I went back and fixed a few things in #49) and also there are references to #49 in various issues in the repro so in order to keep things straighforward for future reference, I think it makes sense to merge #49 and then merge #50. I don't think there will be, but if any conflicts arise in #50 after merging #49 I'll be happy to resolve.
Thanks!
In a situation where a custom collection in a directory of
src/content/docs
is mapped to something other than the physical content collection directory name, the wrong url is generated.It is mentioned in the assumptions located at the top of the README that this scenario is not covered, however I think it would be fairly simple to, at a minimum, handle collection name mappings (path -> directory). Beyond that, for things like handling other path segments, it gets way more complex without internal Astro info and/or metadata in options.
For example, in the following directory structure, the
[...slug].astro
is written to use the content collectiondocs
in the directorydocs
, however the path to the page (virtualized essentially) ismy-docs/test
and notdocs/test
.Repro: https://stackblitz.com/edit/github-pdzrjo-gg4trc
Steps to reproduce:
Collection Root
orCollection Subdir
sectionsExpected Result: The links generated should be
my-docs/[slug]
and navigate successfullyActual Result: The links generated are
docs/[slug]
and 404Debug
pagemy-docs/[slug]
We do not have internal information so there is no current way to detect this situation. Ideas on ways to solve for this situation:
Add an option
collectionNames
which is a key/value pair that makes a physical directory to the collection name. For example, using the above:Leverage metadata in the link in the markdown (similar to the way classes, titles, etc. work)
I think Option 1 makes the most sense as Option 2 is highly dependent on markdown processer, is very error prone and would require every link to have the metadata rather than just a single place to do the mapping as would be the case in option 1.
Thoughts? Other ideas on how to solution and if you think this scenario is worth solving for?