Closed bwbroersma closed 3 years ago
WIP We should probably export everything with children and maybe git tag it after all:
TOKEN="X-Figma-Token: ***";
API="https://api.figma.com/v1"
KEY="EJ4aJwKnemkxysCZ6aAzFv";
STRUCTURE="$(curl -sSfA '' -H "$TOKEN" "$API/files/$KEY/" | jq '.document.children|map({key:.name,value:.children|map(.id)}|select(.value|length>0))|from_entries' -c)"
IMAGES="$(curl -sSfGA '' -H "$TOKEN" "$API/images/$KEY?format=svg" -d "ids=$(echo "$STRUCTURE" | jq 'to_entries|map(.value)|flatten|join(",")' -cr)" | jq '.images' -cr)"
echo -n "{\"images\":$IMAGES,\"structure\":$STRUCTURE}" | jq '.images as $img|.structure|with_entries(.value|=map($img[.]))'
There seem to be some issues with the SVG export, the :warning: and :eyes: on the Cover page are not in the SVG export but are in the PNG.
@bwbroersma nice work. Think pngs will suffice for now, agreed? What do you need to move forward on this?
@jorisleker I agree PNG should be used, there are some more issues with SVG.
Bare minimum:
jq '"# Design\n\n"+(to_entries|map("## \(.key)\n\n"+(.value|map("![Figma screenshot](\(.))")|join("\n"))+"\n")|join("\n"))' -cr
Bonus:
this jq
one-liner addition will create:
The nice thing is, if we publish it as markdown with external images, GitHub will cache the images:
@bwbroersma It would also be nice if we include all text from the designs. Either in the same Markdown file or separate Markdown files. This could help translations and makes the text available for people who can't see the images.
@bramd I was thinking about the alt-text when I made the initial markdown generation, and I think you're right, we can include all text of the Figma in the alt text. This is however more useful for pre 0.4 designs, but they are tricky for 0.4 up, since the board contains quite some text.. any thoughts?
Another thing / nice to have: include Figma issues + comments.
I'm new to Figma (and have never seen them yet) so I should first find out how to see issues + find their API.
@bwbroersma an export would still be nice, but don't think it is a top priority. Closing the issue. Feel free to reopen if you (or others) still intent to work on it 🙂
For all who will not have write access to the Figma, or want a quick peek at the design: would it not be more convenient to export the Figma images to a markdown file that includes these images? Since Figma has an API that can export SVG format images, we could export them version tagged to GitHub.