Topic name says it all: can I get the targeting parameters of a content item as part of the content API response?
My use case is that I have a drawer section model that represents a menu that slides out from the left or the right. Left/right are distinguished using a drawerOrientation custom targeting parameter.
This setup works fine for fetching my drawer content in my layout, because I can specify whether I want a left or right drawer.
But for editing purposes, I have a dedicated editing page that just fetches whichever drawer content item has been opened in the Visual Editor. There’s no knowledge beforehand of whether it’s left or right, but various CSS stylings on my Next.js page depend on knowing this, so I’d like to parse it out of the targeting attributes for that content item if possible.
Argh actually, I answered too soon. The problem is that my query doesn’t have the targeting parameter to begin with, it’s just simply saying “load this content model.”
Looking over the use case, is there a reason this would be based off of targeting parameters? It almost sounds like left and right could just as easily be passed in as values on the data prop to state?
The main reason is that there’s one drawer model and there needs to be a way to select which kind of drawer content item should be rendered, either left or right. I need some kind of targeting parameter for that.
A simple, no-nonsense fix would involve splitting my drawer model into a left-drawer and right-drawer model and creating content items for them separately. That’s what I had originally, but I found that solution unsatisfying and inelegant. Drawer content should just be drawer content. Otherwise, I end up having to write left-drawer and right-drawer all over my codebase.
Do you have a link to an example content entry? How do the left and right drawers differ? If it is just a CSS thing, then you could just have it be conditional based on state passed through data prop.
Without seeing in practice I might be missing some major components of the implementation though