Open stephan-strate opened 3 years ago
That could be useful, so I'd happy for you to integrate it. Looking at the linked JSON, it seems that you would need to put the attribution comment back in for compliance with the Font Awesome Free license, because it's not included in "raw".
<!-- Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) -->
There's also a corresponding JSON file for the Pro license, but it's in a private repo, so it requires an access token to be appended to the address. I'm not sure if there's a convenient way of getting such a token within a Grav site, so I wouldn't consider this a requirement for inclusion.
https://raw.githubusercontent.com/FortAwesome/Font-Awesome-Pro/master/metadata/icons.json?token=ASTRINGOFLETTERSANDNUMBERS
Alternatively, you could query the GitHub API to get the latest release, get the asset URL for the web version, then download it, unzip and just keep the SVGs. I'm not sure that piecing files back together from a JSON makes much sense when we can already get the files directly?
GET https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest
It might also be useful to have the option to upload a zip file and have the plugin automatically unzip it and move the SVGs to the right place.
Thanks for your thoughts! I will think about it again and create a pull request draft for you to review.
After some more thoughts about this topic, this is my conclusion:
Requirements:
The only way I found to get access to the pro icons automatically is using npm. Fontawesome serves an official npm registry, where you can authenticate using the provided access token.
You can not only use the npm registry through npm cli, but also through rest api calls.
Example: GET https://registry.npmjs.org/@fortawesome/fontawesome-free/latest
for the free version.
From there, you can download the tarball and extract the svg icons into the user/data/
folder. You were definitely right about your concerns regarding the creation from the json file. So I am going to use the tarball.
These are my planned features:
user/data/
folderuser/data/
Let me know what you think about this.
Looks like a good plan. I shall look forward to your pull request.
If you don't have Font Awesome Pro and need help testing it, just give me a shout.
@stephan-strate @N-Parsons
What is here now actually?
I created a merge request a while ago. This should still work
Fontawesome provides a json file, what contains all icons as svg. Would you be interested in me integrating a functionality, that downloads the json file and generates svg files from it? This would be optional of course.
Tell me what you think about that :)