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

HTML Object Return - Add option to return html un-stringified (for use in libraries/plugins) #443

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

josh-hemphill
Copy link

@josh-hemphill josh-hemphill commented Oct 29, 2023

closes #442
In other libraries/plugins, it's necessary to separately apply tag data and/or add their own, while still mostly following what favicons supplies.

It took more modification than I'd like to get all the types to return based on the options, but I seem to have got it right, all the tests pass (even made sure the tag order is the same so the snapshots pass), and the return types behave as I'd expect.

For libraries and plugin authors using this downstream, this adds an option to get the html as objects that allow independently tracking the tags and their attributes.
@andy128k
Copy link
Collaborator

Other option would be to expand FaviconResponse and add one more field.

export interface FaviconResponse {
  readonly images: FaviconImage[];
  readonly files: FaviconFile[];
  readonly html: FaviconHtmlElement[]; // string[]
  readonly htmlTags: FaviconHtmlTag[];
}

Then use htmlTags internally and convert htmlTags to html before a return. wdyt?

@josh-hemphill
Copy link
Author

That's kind of what I have it doing. But the different return type means that if you're using the un-stringified return, the stringification doesn't even have to run.
Yeah, I guess it does mean not having the complex generic types, but at the cost of a little more having to run at runtime. I'll go ahead and make the change.

@josh-hemphill
Copy link
Author

Okay, the additional return did simplify things.
Had to update most of the snapshots for the tests.

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.

Option to return un-stringified elements for use in plugins and other libraries
2 participants