Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: allow users to choose a field when embedding inline #336

Open
dboland-rescue opened this issue Jun 16, 2022 · 0 comments
Open

Comments

@dboland-rescue
Copy link

dboland-rescue commented Jun 16, 2022

Background

I recently launched a site for a semi-annual event using Contentful. One of the content types I set up was for the event itself, and it contains fields for event-specific information like registration deadlines, fees, venue location, etc.

The Problem

There are several places on the site where pertinent information pertaining to the event is displayed inline, mid-sentence. But the way inline embedding works, you can only choose the entire record to embed -- once you get to the point of parsing what's been embedded using the renderer package, there's no context for what field you intended to display. Given this fact, I don't really understand what the use case is for inline embedding, unless you were to make a content type for each type of information (ex. price or date), which to me seems like a convoluted workaround. (To be clear, I think it makes perfect sense for block embedding to work the way it currently does.)

My Current Workaround

What I ended up doing to get around this issue -- and it's super hacky and not at all globally applicable -- is to write the label of the field meant for embedding inline and then underline it. Then using the renderer, I look for the underline mark, convert the label to camel-case, checking for a matching field, parse it based on what field it is (date fields are all named uniformly so I can tell what's a date, for instance), and if there's no matching field, just leave it alone. It works, but it's not a great solution as it assumes the intended record.

How It Should Work

In the interface, once you've chosen a record for embedding inline, the next step would be a list of fields for inclusion. The API would return exactly the same payload, except with the inclusion of something like selectedField so as not to introduce breaking changes, while giving developers the proper context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant