#From within a component, how do I get the collection name of the page being rendered?
3 messages · Page 1 of 1 (latest)
Hi @plucky wind. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
I'm sorry, but the knowledge sources do not provide a built-in way to dynamically determine the collection name of the current page from within a component at render time. The documented usage of getCollection() requires you to explicitly provide the collection name as a string argument, such as getCollection('docs') or getCollection('blog') Content Collections API Reference.
There is no mention in the official documentation of a global variable, context property, or API that exposes the current collection name during render. All examples and references require you to know and specify the collection name ahead of time Querying Collections.
If you need to make your component generic, you could pass the collection name as a prop from the parent or page, but this pattern is not described in the knowledge sources.