Skip to content

Conversation

Healios
Copy link

@Healios Healios commented May 15, 2021

What

Added lodash to use _set and _get, in order to support nested cover fields.

Why

The plugin doesn't currently support nested fields, and I would like it to.

I have a website that must be follow WCAG 2.1, and in order to help the web admins stay within those bounds, I must require alt descriptions on images, when the images aren't decorative.

This means I have a collection with a cover field that is an object and not an image.
image

How to use

The plugin will function as usual when accessing a direct field:
coverField: "cover"

To specify a nested field, simply access it like you would in Javascript code (with a dot in between):
coverField: "cover.image"

@Healios
Copy link
Author

Healios commented May 26, 2021

Hi @tyrion

I hope I'm not being impatient, but could you have a look at this? Alternatively, could you license this project?

@tyrion
Copy link
Owner

tyrion commented May 26, 2021

Hey @Healios,

you are absolutely right about the license, I should do that asap. Anyway, regarding your issue, I wouldn't mind supporting your use case, however it feels a bit overkill to add lodash as a dependency just for this. I am not sure if it's a good idea.

I also did not understand what is preventing you from moving "cover.image" to the top level?

@Healios
Copy link
Author

Healios commented May 27, 2021

@tyrion

While I do agree with the sentiment, that it feels overkill to add lodash and that one shouldn't needlessly add dependencies, I think there's a good reason as to why it shouldn't be a problem.

This plugin is only used during buildtime and as a result no bloat is introduced to the website dist. There's also the argument that one shouldn't reinvent the wheel.

I ultimately used lodash because Javascript isn't my main language, and that it was an otherwise elegant and quick solution (code-wise). If necessary, I will write the methods myself.

You're right, I could technically just move all of the fields to the top level, - I guess it's just an organisational thing.    

@Healios
Copy link
Author

Healios commented Jun 4, 2021

@tyrion Any news on license or my latest comment?

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

Successfully merging this pull request may close these issues.

2 participants