[Feature Request] Additional formats for customapi widget #1870
Replies: 2 comments
-
This discussion has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
It would be nice to have more formats, especially
bytes
for the customapi widget. I looked into adding this myself by including atemplate
option for eachfield
inmappings
(e.g.{{value, byte(binary: true)}}
) that hascustom
format type, which works well, the only problem is that not all APIs are guaranteed to use bytes directly over something already scaled (MiB/KiB). But there was no good way to try and re-scale it to bytes through the yaml, so I added ascale
option toprettyBytes
(https://github.com/benphelps/homepage/blob/main/next-i18next.config.js) with a modification like this:with a usage like
This works, and correctly formats the size.
I'm just not sure this implementation above is really the best solution to this problem. It might be better to scale it somehow in the
customapi
widget directly and usecommon.bbytes
and not allow fully custom template strings like I did.Maybe shamoon or benphelps will have a better idea for implementation.
Other
No response
Beta Was this translation helpful? Give feedback.
All reactions