Single Content Type
See original GitHub issueHey,
I was wondering whether single content type can be somehow plugged in?
What I mean is that suppose there is a collection “pages” where each doc id is page name and each document has different structure.
For example /pages/about, /pages/home.
about
and home
are document ids. Each document has its own unique structure.
Firecms navigation is an array of collections and every collection must follow defined schema (Entity). The easiset workaround I can think of right now is to build multiple views for a single collection and apply filter on a document field that uniquely identifies that document in the collection:
const navigation: EntityCollectionView[] = [
buildCollection({
group: 'Pages',
name: 'Home',
relativePath: 'pages',
schema: homePageSchema,
initialFilter: {
page: ['==', 'home']
}
}),
buildCollection({
group: 'Pages',
name: 'About',
relativePath: 'pages',
schema: aboutPageSchema,
initialFilter: {
page: ['==', 'about']
},
})
];
Although each document needs an additional field in order to be uniquely filtered out, theoretically it should work.
However… This does not work in reality. Firecms generates views based on path in firestore.
With above workaround, ‘Single-Types’ will share the same view: /c/pages
that will display only first matched EntityCollectionView. Maybe an additional prop to specify custom route will do the trick?
An ideal API would look something like:
buildSingleType({
group: 'Pages',
name: 'Home',
relativePath: 'pages/home',
schema: homePageSchema,
})
Let me know what do you think
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Great to hear! Please let me know how things go for you from now on, your feedback was really valuable! 😃
Everything works smoothly. I will stick with schema passed directly to
useSideEntityController
. At the moment, there is no need for me to use customschemaResolver
.Single content type was succesfully achieved haha 😃 And it’s even better than that since independent documents can be grouped together in an AdditionalView. That was super useful update!