question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Single Content Type

See original GitHub issue

Hey,

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:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
fgatti675commented, Feb 17, 2021

Great to hear! Please let me know how things go for you from now on, your feedback was really valuable! 😃

0reactions
shelooks16commented, Feb 16, 2021

Everything works smoothly. I will stick with schema passed directly to useSideEntityController. At the moment, there is no need for me to use custom schemaResolver.

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Single vs Multiple Content Types (Website Examples)
“Single” lets you create a single entry using the content type, while “Multiple” lets you create more than one entry of the same...
Read more >
Content-Type - HTTP - MDN Web Docs - Mozilla
The Content-Type representation header is used to indicate the original media type of the resource (prior to any content encoding applied ...
Read more >
Content-type Builder - Strapi User Guide
Single types are content-types that can only manage one entry. Components are a data structure that can be used in multiple collection types...
Read more >
Content types | Understanding Drupal
A single web site could contain many types of content, such as informational pages, news items, polls, blog posts, real estate listings, ...
Read more >
A content type for one entry only - Misc Technical Topics
I have Home Page and Page Footer content types which each only has exactly one active entry at any given time. Is this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found